ThinkingSphinx 和回调在创建记录后不更新索引

问题描述 投票:0回答:0
# 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

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

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

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

或者基本的SQL索引不知道新增记录时如何更新索引?

如果是这样,那么对于一个小项目来说,sql with deltas 和 real_time 哪个更好?

Sphinx 2.2.11-id64-release (95ae9a6)
rails (6.1.7.2) & PostgreSQL
thinking-sphinx (5.5.1)
ruby-on-rails activerecord full-text-search thinking-sphinx
© www.soinside.com 2019 - 2024. All rights reserved.