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.
CodePudding user response:
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