Reputation: 35
We are using Elasticsearch (6.1) for indexing. We used to update our documents on daily basis. We are facing problems with count API. Basically we are getting the incorrect count.
My analysis came out that it's because of how Lucene handles the doc update query.(So it's count of deleted document and updated document) I referred this blog(https://www.elastic.co/blog/lucenes-handling-of-deleted-documents)
After a day or two count starts coming correct. it's happening every time when some lot of docs got updated.
Can this thing be fixed so that we can get correct count in real time.
Upvotes: 0
Views: 782
Reputation: 14492
Once you have updated your documents (indexed or deleted), if you need to immediately query them, you need to refresh the index.
For example
DELETE test
PUT test/doc/1
{
"user": "kimchy"
}
PUT test/doc/2
{
"user": "kimchy"
}
DELETE test/doc/1
POST test/_refresh
GET test/_count
Should give you 1 document.
By default, the refresh is done every second. So unless you change this index setting, I can't see how you would have to wait for a day to get accurate results.
Upvotes: 1