-
I'm trying to write a few integration tests for some application code that interacts with elasticsearch in a spring boot application. However, I seem to have an issue with the I can connect to the container fine and other methods work ok. I can index the document and retrieve it using the I know the queries work since I have tried running them in the application code and they work fine against a standard elasticsearch container. I've tried with and without an index template in case there is something about the document that would prevent it from being searchable but that has not solved it. I've tried a few other configurable options as shown in the commented out code but that again hasn't changed anything. For reference I am running elasticsearch version 7.10.2 and testcontainers version 1.17.6. I'm not sure if I am missing something fairly obvious since I can't imagine that testcontainers won't support the search functionality of elasticsearch.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
This issue has been resolved. For future reference, the
|
Beta Was this translation helpful? Give feedback.
This issue has been resolved. For future reference, the
search
API within elastic is not real-time like theget
API. Therefore it is not possible for the java application to index a document and immediately search for it. The dummy test has been changed to below. In my actual test, I have calledelasticSearchClient.indices.refresh(RefreshRequest)
after indexing the data as a workaround to avoid usingThread.sleep
.