Elasticsearch + Java - Can you further optimize this query?

We have an elasticsearch that contains millions of records and we are using it for a global searching. However, our query takes 2-4 seconds to return result. Can somebody help or advice how to further optimize the following query:

    NativeSearchQueryBuilder query = new NativeSearchQueryBuilder()
    .withQuery(QueryBuilders.boolQuery()
        .should(QueryBuilders.termQuery("name", searchText))
        .should(QueryBuilders.termQuery("key", searchText))
        .should(QueryBuilders.termQuery("sort_alpha", searchText))
        .should(QueryBuilders.termQuery("sort_number", searchText))
    ).withPageable(PageRequest.of(0, 100))
    .withHighlightFields(new HighlightBuilder.Field("name"),
        new HighlightBuilder.Field("key"),
        new HighlightBuilder.Field("sort_alpha"),
        new HighlightBuilder.Field("sort_number")
    .build();

What is the value of the took field in the response object?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.