Different results with/without preference=_primary_first/_replica_first using count API

Hi,

I'm bulk indexing massive data however when I check the status, I found
some interesting results:

When I called: curl -XGET
'http://localhost:9200/my_index/my_type/_count?pretty' -d '{"query" : {
"filtered": {"filter" : {"exists" : {"field": "visibility"}}}}}}'

It returned:
{
"count" : 27395968,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
}
}

When I called: curl -XGET
'http://localhost:9200/my_index/my_type/_count?pretty&preference=
_primary_first' -d '{"query" : { "filtered": {"filter" : {"exists" :
{"field": "visibility"}}}}}}'

It returned as below.
{
"count" : 36802421,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
}
}

As we can see, there is a hugh difference between the the above two
results. So I thought it was caused by the inconsistency between the
primary shard and the replicas.

Then I called curl -XGET
'http://localhost:9200/my_index/my_type/_count?pretty&preference=
_replica_first' -d '{"query" : { "filtered": {"filter" : {"exists" :
{"field": "visibility"}}}}}}'

To my surprise, the count is roughly the same(slight difference caused by
bulk indexing that I'm still running).

{
"count" : 36867417,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
}
}

So any idea why this happen?

Thanks!

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/df5ac31e-ad17-4b8c-b979-18c4a977bb0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.