认为 Sphinx Delta 索引不起作用
我已将增量列添加到我的表中:
class AddDeltaIndexToCimgs < ActiveRecord::Migration
def change
add_column :cimgs, :delta, :boolean, default: true, null: false
end
end
我迁移了,
我还添加了define_index:
define_index do
indexes search_cache
has :approved
set_property delta: true
end
并且我运行了rake任务
rake ts:stop
rake ts:index
rake ts:start
或rake ts:rebuild
然后我向表中添加了一条新记录,搜索它。 ..什么也没有。 可以完美找到核心索引记录,但增量根本不起作用。
为了搜索它们,我使用以下命令:
Cimg.search query, with: {approved: true}
是的,每个 Cimg 都经过批准,并且在 search_cache 中有一堆内容,并且新内容在数据库中标记为 delta=1。我仔细检查了。
我检查了 db/sphinx 文件夹,并创建了许多名为 cimg_delta
的文件。
这是生成的配置文件: http://pastebin.com/z0fHr43k
Sphinx version: 2.0.7
Thinking Sphinx gem version: 2.0.5
Rails version: 3.1.0.rc8
Ruby version: 1.9.2p290
知道为什么会发生这种情况吗?
I have added the delta column to my table:
class AddDeltaIndexToCimgs < ActiveRecord::Migration
def change
add_column :cimgs, :delta, :boolean, default: true, null: false
end
end
I migrated
I also added the define_index:
define_index do
indexes search_cache
has :approved
set_property delta: true
end
And I ran the rake tasks
rake ts:stop
rake ts:index
rake ts:start
Or rake ts:rebuild
Then I add a new record to the table, search for it... and nothing.
The core-indexed records can be found perfectly, but the delta is not working at all.
To search them I use the following:
Cimg.search query, with: {approved: true}
And yes, every Cimg is approved, and have a bunch of stuff in search_cache, and the new ones are marked with delta=1 in the database. I double checked.
I checked the db/sphinx folder and a lot of files with the name cimg_delta
are created.
Here is the generated configuration file: http://pastebin.com/z0fHr43k
Sphinx version: 2.0.7
Thinking Sphinx gem version: 2.0.5
Rails version: 3.1.0.rc8
Ruby version: 1.9.2p290
Any idea of why this may be happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是一个健全性检查,但在你的 config/sphinx.yml 文件中
你在做什么
确保你已经添加了任何新的索引模型,否则认为 sphinx 只会索引每个环境下指定的模型。我刚刚向用户模型添加了一个define_index,但无法弄清楚为什么在运行
rake ts:rebuild
时它没有被索引我忘记将indexed_models: user添加到shinx.yml希望这有帮助,谢谢戴夫
Just a sanity check but in your config/sphinx.yml file
are you doing
Make sure you have added any new indexed models otherwise thinking sphinx will only index the ones specified under each environment. I just added a define_index to User model and couldn't figure out why it wasnt being indexed when running
rake ts:rebuild
I had forgotten to add the indexed_models: user to shinx.ymlHope this is helpful, Thanks Dave