1

I tried to implement a full text search in spring data elasticsearch, but when a request is sent this exception is raised "Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]"

MultiMatchQueryBuilder queryBuilder = QueryBuilders.multiMatchQuery(searchTerm)
                .type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
                .operator(Operator.AND)
                .field("firstName")
                .field("lastName")
                .field("activeDirectoryUsername")
                .field("employeeNumber")
                .field("personalEmail")
                .field("corporateEmail")
                .field("project");

        SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder()
                .postFilter(queryBuilder);

        SearchRequest request = new SearchRequest("employee");
        request.source(searchSourceBuilder);

        SearchResponse response = client.search(request, RequestOptions.DEFAULT);

the exception is raised in the last line.

1
  • what is the motive for use postFilter? Commented Aug 20, 2022 at 12:06

1 Answer 1

1

The problem was in the employeeNumber field, I don't know if it because it a long or because, it was a Long when the index was created and I changed it to a String and a mismatch occured between the index and my spring document but it worked find after I deleted the index and recreated it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.