How long does it take from getting a document upserted into ES before it can be searched against correctly?

独自空忆成欢 提交于 2019-12-11 14:53:44

问题


I'm using ES to retrieve data, which I change and update back in ES followed by doing the same search query - it looks like I don't always get the updated document back down and have to wait a second or two.

Using the following code:

esClient.Update<TESDocModel, TESDocModel>(new DocumentPath<TESDocModel>(docId), u => u.Index(index).Doc(toUpdate).DocAsUpsert(true));

Is this correct behaviour or should a document be immediately searchable after the upsertdocument operation is complete?


回答1:


This depends on when refresh action on the shard is performed. When a document is indexed it is not searchable immediately. To make is searchable refresh action on a shard is performed. This behind the scenes writes and opens a new segment making the documents that are contained in those segments to be searchable.

By default elastic refreshes shard every second. This is why it is said that Elasticsearch has near real-time search.

The refresh interval can be controlled by index setting param refresh_interval. For e.g the below will change the refresh interval to 5 seconds and any new document indexed will at max take 5 secs to be searchable.

PUT /my_index
{
  "settings": {
    "refresh_interval": "5s" 
  }
}

To understand more on it read about elasticsearch near real time search.



来源:https://stackoverflow.com/questions/55331154/how-long-does-it-take-from-getting-a-document-upserted-into-es-before-it-can-be

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!