【发布时间】: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