total_entries
我注意到我的结果计数有些奇怪。
索引我的文档时,我看到有 8027 个文档被索引:
using config file 'myapp/config/production.sphinx.conf'...
indexing index 'variant_nl_core'...
collected 8027 docs, 2.0 MB
collected 16124 attr values
sorted 0.0 Mvalues, 100.0% done
sorted 7.4 Mhits, 100.0% done
total 8027 docs, 2007375 bytes
total 15.138 sec, 132600 bytes/sec, 530.23 docs/sec
indexing index 'variant_nl_delta'...
collected 0 docs, 0.0 MB
collected 0 attr values
sorted 0.0 Mvalues, 100.0% done
total 0 docs, 0 bytes
total 0.010 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index 'variant_nl'...
indexing index 'variant_fr_core'...
collected 8027 docs, 2.0 MB
collected 16124 attr values
sorted 0.0 Mvalues, 100.0% done
sorted 6.6 Mhits, 100.0% done
total 8027 docs, 2048826 bytes
total 16.959 sec, 120808 bytes/sec, 473.31 docs/sec
indexing index 'variant_fr_delta'...
collected 0 docs, 0.0 MB
collected 0 attr values
sorted 0.0 Mvalues, 100.0% done
total 0 docs, 0 bytes
total 0.013 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index 'variant_fr'...
total 64311 reads, 0.045 sec, 1.2 kb/call avg, 0.0 msec/call avg
total 209 writes, 0.097 sec, 789.4 kb/call avg, 0.4 msec/call avg
当我使用 nil 作为查询进行搜索时,我希望所有 8027 文档都与搜索匹配。
r = Variant.search nil
但是当我检查匹配条目的数量时total_entries
,我实际上得到了更多的结果:
r.total_entries
=> 15054
这怎么可能 ?我错过了什么?
2015 年 9 月 23 日更新
正如 Eugene 所建议的,多个索引是我的问题的原因:
“total_entries”计算在所有索引(_core 和 _delta)中找到的文档数。
现在,我需要一种方法来知道我的模型('Variant')有多少实例对应于 sphinx 文档。