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

时间:2012-05-24 13:08:25

标签: sphinx thinking-sphinx

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

一切都运转良好

直到我决定用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
甚至看到Ryan Bates Screencast 他似乎用“ has ”方法定义了条件子句 列

类似

 has :author_id

阅读Pate Allen的post之一(向下滚动到底部

 :with should be used for attribute filters, and :conditions for
field queries. 

所以使用子句

更改上面的代码
PartPriceRecord.search "PartNumber50002",:with => {:supplier_id =>
"supp50002" },:star => true

我没有得到任何错误的结果,因为我可以查看记录 part_number“PartNumber50002”的“supplier_id”按数据库

现在我很困惑

为什么上面的错误出现以及根本区别是什么 在“字段”和“属性”之间

任何人都可以提供帮助

BTW在这里我的索引定义

 define_index  do
   indexes part_number
   has supplier_id
 end

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

1 个答案:

答案 0 :(得分:1)

在Sphinx中,目前只能过滤数字属性。 :supplier_id => “supp50002”表示字符串属性。

我不懂红宝石或思维 - 狮身人面像。但看到潜在的狮身人面像不能做到这一点,我猜思考 - 狮身人面像不会允许它。

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

  • 而属性只是按原样存储在索引中。它们对于后续[1],排序,分组和直接过滤非常有用。条件是不支持按字符串属性过滤。可以按其他属性过滤

[1] Sphinx可以在结果集中返回属性值;而字段没有存储 - 只有索引,所以你不要让它们回来