ThinkingSphinx & callback 在创建记录后不更新索引


# index
ThinkingSphinx::Index.define :review, with: :active_record do
indexes title, sortable: true
indexes body
indexes author.username, as: :author, sortable: true
has author_id, created_at, updated_at
end
# model
class Review < ApplicationRecord
...
ThinkingSphinx::Callbacks.append(
self, :behaviours => [:sql]
)
end

新记录不出现在搜索中,索引不更新自己。
VIA: https://freelancing-gods.com/thinking-sphinx/v5/indexing.html#callbacks

当您删除一条记录时,它会从搜索中消失,但我不确定它是否与更新索引有关,因为索引文件不会更改。

如果我通过rake运行更新,新条目将出现在搜索中。
在另一个项目中,索引通过每当的任务更新。

或者基本SQL索引不知道如何在添加新记录时更新索引?

如果是这样的话,那么对于一个小项目来说,选择带delta的sql和real_time哪个更好呢?

Sphinx 2.2.11-id64-release (95ae9a6)
rails (6.1.7.2) & PostgreSQL
thinking-sphinx (5.5.1)

https://github.com/pat/thinking-sphinx/blob/13d0db24ce14a45bc6757b79760bb341d0185360/lib/thinking_sphinx/callbacks/appender.rb#L26

add_core_callbacks只调用:destroy
事实证明,我需要使用sql与delta或real_time

最新更新