思考 Sphinx“在模式中找不到字段”错误
我对狮身人面像还很陌生。
尝试查找名为“bob”且 company_id“14”的用户。
Controller:
@users = User.search 'bob', :conditions => { :company_id => '14'}
Model:
define_index do
indexes :name
indexes :company_id
end
Error:
index user_core: query error: no field 'company_id' found in schema
我在表中有“company_id”&我多次重新索引所有内容。 当我只是搜索“名称”时,一切正常。
I am pretty new to Sphinx.
Trying to find user with name "bob" and company_id "14".
Controller:
@users = User.search 'bob', :conditions => { :company_id => '14'}
Model:
define_index do
indexes :name
indexes :company_id
end
Error:
index user_core: query error: no field 'company_id' found in schema
I have the 'company_id' in table & I re-indexed everything several times.
When I am just searching for the 'name' everything works properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如另一个有用的提示:事实证明我必须更改调用
Model.search()
的方式,因为我的字段被列为属性(即使用has
),我需要使用:with
而不是:conditions
(对于字段)调用search
方法。Just as another helpful hint: turns out I had to change the way I called
Model.search()
, since my field was listed as an attribute (i.e. usinghas
), I needed to call thesearch
method with:with
instead of:conditions
(for fields).属性应声明为:
因此,在您的情况下:
Attributes should be declared as:
So, in you case:
还有一个更有用的提示,如果您碰巧是像我一样的白痴:
如果您收到此错误并且您正确使用属性和字段,则可能是您在向索引添加新字段后忘记重新启动开发服务器。
And one more helpful hint, if you happen to be an idiot like me:
If you are getting this error and you are correctly using attributes and fields, it may be that you forgot to restart your dev server after adding a new field to the index.