Sorry, just to be clear: :with is for attributes, and :conditions is for fields.

This wasn't always the case (in old versions of Thinking Sphinx, filters for 
both fields and attributes could be in :conditions), but all recent releases 
require them to be separated into :with and :conditions appropriately.

Now, specific to your case, supplier_id seems to be a string - and string 
attributes cannot be filtered on. If you change it to a field, then perhaps you 
can filter on it using :conditions - but you're also dealing with Sphinx's 
query language and word token parsing there, which can sometimes get in the way.

Hope this helps.

-- 
Pat

On 24/05/2012, at 6:55 PM, Viren wrote:

> Thanks Point noted
> But just to confirm you said  "You should definitely be using :with"
> and "supplier_id is a string, then you can't filter on it when it's an
> attribute."
> 
> so that take "with" out of the picture can I use conditions now apart
> for that amazing hack you just mention in the link
> 
> and why did the conditions at first place blew so badly .
> 
> 
> Can you comment on it
> 
> Thanks
> 
> 
> 
> On May 24, 8:05 pm, Pat Allan <[email protected]> wrote:
>> HiViren
>> 
>> You should definitely be using :with (at the time of Ryan's screencast, 
>> Thinking Sphinx allowed for both field and attribute filters in :conditions, 
>> but that's no longer the case).
>> 
>> But also, if supplier_id is a string, then you can't filter on it when it's 
>> an attribute. Potentially, you would work around it, though it may be worth 
>> just making it a field 
>> instead:http://freelancing-god.github.com/ts/en/common_issues.html#string_fil...
>> 
>> As for the difference between fields and attributes - fields are the textual 
>> data that you generally expect your website's users to enter, whereas 
>> attributes are usually not strings, and are used for internal filters and 
>> sorting. There's a bit more of an explanation 
>> here:http://freelancing-god.github.com/ts/en/sphinx_basics.html
>> 
>> Cheers
>> 
>> --
>> Pat
>> 
>> On 24/05/2012, at 11:04 PM,Virenwrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> If Set up Thinking Sphinx on my application now
>> 
>>> Everything was workinf fine
>> 
>>> Until I decide to do a conditions query with Thinking Sphinx
>> 
>>> PartPriceRecord.search "50002" ,:conditions => { :supplier_id =>
>>> "supp50002" },:star => true
>> 
>>> and it reported me with the above error
>> 
>>> ThinkingSphinx::SphinxError: index part_price_record_core: query
>>> error: no field 'supplier_id' found in schema
>> 
>>> seeing even the Ryan Bates 
>>> Screencasthttp://railscasts.com/episodes/120-thinking-sphinx
>>> he seem to achieve the conditions clauses with "has" method defined
>>> for the column
>> 
>>> something like
>> 
>>> has :author_id
>> 
>>> Reading to one of the post by Pate Allen (scroll down to bottom)
>> 
>>> https://groups.google.com/group/thinking-sphinx/browse_thread/thread/...
>> 
>>> " :with should be used for attribute filters, and :conditions for
>>> field queries. "
>> 
>>> so changing my above code with clause
>> 
>>> PartPriceRecord.search "PartNumber50002",:with => {:supplier_id =>
>>> "supp50002" },:star => true
>> 
>>> and  I get no result which is wrong as I can see Record for
>>> "supplier_id" for part_number "PartNumber50002" in by database
>> 
>>> Now I'm confuse
>> 
>>> why is above error appearing and also what the fundamental difference
>>> between "fields" and "attribute"
>> 
>>> can anyone help
>> 
>>> BTW here my indexes definition
>> 
>>> define_index  do
>>>    indexes part_number
>>>    has supplier_id
>>>  end
>> 
>>>  sphinx_scope(:supplier) { |name|
>>>    {:conditions => {:supplier_id => supplier}}
>>>  }
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Thinking Sphinx" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/thinking-sphinx?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to