1
I need to perform a search in Elastic search, but I’m having difficulties
BoolQueryBuilder query = boolQuery()
.must(matchQuery(CLIENT_ID, clientId));
fieldValues
.forEach(fieldValue -> query.must(boolQuery().should(matchQuery(FIELD_NAME, fieldValue))));
fieldValues is a list of strings. And I would like to have the match result of all the values I have in the list with the FIELD_NAME field. But the way I implemented it, it results 0 always, because from what I understand, he tries to match with the first value AND all the rest. I’d like an OR operation, not AND.
I never used this java api for Elasticsearch, but apparently the problem is the use of MUST. I believe you do not need the Must written inside the foreach, try calling the query directly.should(matchQuery(FIELD_NAME, fieldValue)).
– Gabriel Coletta
Hello man. Man, thanks for the answer, but as a result everything comes. I imagine it is by the query from above. It seems that everything that belongs to the customer’s id is taken. When it comes time to give the match, he does not disregard those who do not give match. If it helps, I can show the resulting query.
– Jonathan