Skip to content

Elasticsearch search method returning 0 hits #6393

Answered by aliktb
aliktb asked this question in Q&A
Discussion options

You must be logged in to vote

This issue has been resolved. For future reference, the search API within elastic is not real-time like the get 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 called elasticSearchClient.indices.refresh(RefreshRequest) after indexing the data as a workaround to avoid using Thread.sleep.

@Testcontainers
public class SampleTest {

    static String ELASTICSEARCH_VERSION = "7.10.2";

    @Shared
    @Container
    private static ElasticsearchContainer esContainer =
            new ElasticsearchContainer(
                    DockerImageName.parse("docker.elastic.co…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@kiview
Comment options

@aliktb
Comment options

Answer selected by aliktb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants