Sphinx守护程序返回错误:查询错误:无字段

Sphinx守护程序返回错误:查询错误:无字段,sphinx,thinking-sphinx,Sphinx,Thinking Sphinx,如果现在在我的应用程序上设置Thinking Sphinx 一切正常 直到我决定用斯芬克斯做一个条件查询 PartPriceRecord.search "50002" ,:conditions => { :supplier_id => "supp50002" },:star => true 它向我报告了上述错误 ThinkingSphinx::SphinxError: index part_price_record_core: query error: no field 's

如果现在在我的应用程序上设置Thinking Sphinx

一切正常

直到我决定用斯芬克斯做一个条件查询

PartPriceRecord.search "50002" ,:conditions => { :supplier_id =>
"supp50002" },:star => true
它向我报告了上述错误

ThinkingSphinx::SphinxError: index part_price_record_core: query
error: no field 'supplier_id' found in schema
甚至连瑞安·贝茨都看到了 他似乎用“已经定义了”方法来实现条件子句 专栏

差不多

 has :author_id
阅读Pate Allen的一篇文章(向下滚动至底部)

因此,使用
子句更改上述代码

PartPriceRecord.search "PartNumber50002",:with => {:supplier_id =>
"supp50002" },:star => true
我没有得到任何错误的结果,因为我可以看到 按数据库中零件号“零件号50002”的“供应商id”

现在我很困惑

为什么会出现上述错误,还有什么根本区别 在“字段”和“属性”之间

有人能帮忙吗

顺便说一句,这里是我的索引定义

 define_index  do
   indexes part_number
   has supplier_id
 end

 sphinx_scope(:supplier) { |name|
   {:conditions => {:supplier_id => supplier}}
 }

在Sphinx中,当前只能过滤数值属性:供应商id=> “supp50002”表示字符串属性

我不懂鲁比或斯芬克斯。但鉴于潜在的斯芬克斯无法做到这一点,我猜斯芬克斯不会允许的

  • 字段是原始数据集中的文本列。Sphinx为它们编制索引,可以通过主“全文查询”进行查询

  • 而属性只是按索引中的原样存储。它们可用于检索[1]、排序、分组和直接过滤。但前提是不支持按字符串属性筛选。可以按其他属性筛选


[1] Sphinx可以在结果集中返回属性值;然而,字段并不是只存储在索引中,所以您无法将其取回

您的权利仍然是附加pat回答的链接以供进一步参考
 define_index  do
   indexes part_number
   has supplier_id
 end

 sphinx_scope(:supplier) { |name|
   {:conditions => {:supplier_id => supplier}}
 }