Elasticsearch is Near Real Time. Which in short it indicates that after issuing an insert request, it will not directly appear to all search and aggregation queries.
In my application I first insert a document then at later stage in execution logic i run an aggregation, I dont see the inserted document result within the aggregated result.
In order to force new inserts,updates and deletes to appear in search results you cancall the refresh API before your aggregation. Be aware that this can cause a lot of performance problems if done frequently though as making data available for search is an expensive operation (which is why Elasticsearch is near-real time).
For the documents to be searchable a refresh have to occur, so there are no alternatives. You could force a refresh at indexing time, which would remove the need for a separate API call, but that would likely have an even bigger negative impact on performance.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.