加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 为什么我的索引缺少Thinking Sphinx的文档?

发布时间:2020-12-17 02:00:45 所属栏目:百科 来源:网络整理
导读:我在我的帐户模型上定义了一个简单的Thinking Sphinx索引: define_index do indexes display_name indexes email_addresses.email_address has created_at set_property :delta = :datetime,:threshold = 2.minutesend (暂时忽略delta;我正在生成完整索引并
我在我的帐户模型上定义了一个简单的Thinking Sphinx索引:

define_index do
  indexes display_name
  indexes email_addresses.email_address

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

(暂时忽略delta;我正在生成完整索引并搜索account_core.)

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

>> Account.count
# => 885138

>> Account.search.total_entries
# => 260795

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

但是,在命令行上,使用搜索实用程序,我能够找到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,created_at=Tue Dec 27 12:01:12 2011

实际上这些是Drew的帐户ID.

为什么在使用Thinking Sphinx搜索时无法找到Lenny?为什么total_entries数量远小于accounts表中的总行数?

解决方法

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

感谢#sphinxsearch中的roman3x指向我.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读