Home > front end >  Query ElasticSearch after the index operation
Query ElasticSearch after the index operation

Time:09-22

I have the eservice A that executes some text processing. After it, service B has to execute some set of Elasticsearch queries on the document. The connectivity between the services provided by Kafka. The solution is tightly coupled to ES free text search capabilities, so I can't query in another way.

Possible solution: To store the document in ES and query it. The problem is that ES is eventually consistent and I don't know if the document already indexed or not. Is there some API to ensure that the document is already indexed?

Another option is to publish a message from service A with delay X 5 seconds, where X is the refresh interval of the index, where the document should be stored. Seems to me an unreliable solution. What do you think?

Another direction that I thought about, is some way to query the document with ES queries where the document is in memory. For example, if I will have some magic way to convert the ES query to Luciene DSL, so I don't need to deal with the eventual consistent behavior of Elasticsearch and I can query Lucine directly.

Maybe there are some other solutions?

CodePudding user response:

take a look at the ?refresh flag so that an indexing request will only return once a refresh has happened. otherwise you can use the GET API to see if the document exists or not

however there is no magic options here, Elasticsearch is eventually consistent and you need to factor that in

  • Related