简体   繁体   English

Thinking Sphinx:具有多个索引的模型的唯一结果计数

[英]Thinking Sphinx : unique results count for model with multiple indices

I noticed something strange with the total_entries count for my results.我注意到我的结果的total_entries计数有些奇怪。

When indexing my document, I see that there are 8027 documents indexed :在索引我的文档时,我看到有 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

When I do a search with nil as query, I'd expect to have all 8027 document matching the search.当我使用 nil 作为查询进行搜索时,我希望所有 8027 文档都与搜索匹配。

r = Variant.search nil

But when I check the number of matching entries with total_entries , I actually get more results :但是当我用total_entries检查匹配条目的数量时,我实际上得到了更多的结果:

r.total_entries
 => 15054 

How is this possible ?这怎么可能 ? What I am missing ?我缺少什么?

UPDATE 23/09/2015更新 23/09/2015

As suggested by Eugene, multiple indices are the cause of my issue :正如尤金所建议的,多个索引是我的问题的原因:

'total_entries" counts the number of documents found in all indeces (_core and _delta). 'total_entries' 计算在所有 indeces(_core 和 _delta)中找到的文档数。

Now, I would need a way to know how many instance of my model ('Variant') corresponds to the sphinx documents.现在,我需要一种方法来知道我的模型('Variant')有多少实例对应于 sphinx 文档。

As I see from your index log, you have 2 indexes: 'variant_nl' and 'variant_fr', each index contains 8027 documents.正如我从您的索引日志中看到的,您有 2 个索引:'variant_nl' 和 'variant_fr',每个索引包含 8027 个文档。 So in total you have 15054 documents.所以你总共有 15054 个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM