Reputation: 5962
If Set up Thinking Sphinx on my application now
Everything was working 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 Screencast 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)
: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 a 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}}
}
Upvotes: 0
Views: 729
Reputation: 21091
In Sphinx, currently only numeric attributes can be filtered. :supplier_id => "supp50002" suggests a string attribute.
I dont understand ruby or thinking-sphinx. But seeing as the underlying sphinx cant do that, I'm guessing thinking-sphinx wont allow it.
fields, are textual columns from the original dataset. Sphinx indexes them, and they are queryable via the main 'full text query'.
Whereas attributes, are just stored as is in the index. They are useful for retrivial[1], sorting, grouping and direct filtering. With the provisio that filtering by string attributes is not supported. can filter by other attributes
[1] Sphinx can return the values of attributes, in the resultset; whereas fields are not stored - only indexed, so you dont get them back
Upvotes: 1