【问题标题】:Why is my index missing documents with Thinking Sphinx?为什么我的索引缺少 Thinking Sphinx 的文档?
【发布时间】:2023-04-03 15:23:01
【问题描述】:

我在Account 模型上定义了一个简单的 Thinking Sphinx 索引:

define_index do
  indexes display_name
  indexes email_addresses.email_address

  has created_at
  set_property :delta => :datetime, :threshold => 2.minutes
end

(暂时忽略增量;我正在生成完整索引并搜索account_core。)

但我得到了一些意想不到的结果:

>> Account.count
# => 885138

>> Account.search.total_entries
# => 260795

>> Account.search("lenny@paperlesspost.com")
# => []

但是,在命令行上,使用 search 实用程序,我能够找到 Lenny:

$ search -c /etc/sphinx/water.sphinx.conf -i account_core drew@example.com

index 'account_core': query 'drew@example.com.com ': returned 2 matches of 2 total in 0.759 sec

displaying matches:
1. document=3543432, weight=4, sphinx_internal_id=442101, sphinx_deleted=0, class_crc=0, created_at=Mon Apr 11 12:18:08 2011
2. document=5752816, weight=2, sphinx_internal_id=719552, sphinx_deleted=0, class_crc=0, created_at=Tue Dec 27 12:01:12 2011

这些确实是 Drew 的帐户 ID。

为什么我在使用 Thinking Sphinx 搜索时找不到 Lenny?为什么total_entries 的数字比accounts 表中的总行数小很多?

【问题讨论】:

    标签: ruby-on-rails sphinx thinking-sphinx


    【解决方案1】:

    事实证明,问题与 Thinking Sphinx 如何处理单表继承有关。 TS 仅返回具有与父类的子类之一对应的type 的记录。如果typeNULL,则该文档不包含在搜索结果中。我们在accounts 表中有很多记录,type=NULL。修复数据后,现在可以按预期进行搜索。

    感谢 #sphinxsearch 中的 roman3x 向我指出这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多