Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): 2.6
I have a search request with a query. I’m sure that in the result set should be some hits, but the result set is returned empty. The query works in the opensearch console.
Maybe the search request is constructed in the wrong way or I use the wrong query types?
The response status is 200 and there are no exceptions.
Edit: now I’m getting this Exception: org.opensearch.client.util.MissingRequiredPropertyException: Missing required property ‘SearchResponse.took’ and I don’t know how to get rid of these.
Relevant Code:
List<Query> filter = getFilter(query);
BoolQuery qb = QueryBuilders.bool().must(filter).build();
List<Query> getFilter(NeuigkeitQuery query) {
List<Query> matchQueries = new ArrayList<>();
matchQueries.add(addFilterQueryIfFilterIsSelected("oberbayern", "bezirke")._toQuery());
...
return matchQueries;
}
TermsQuery addFilterQueryIfFilterIsSelectedString filter, String field) {
if (StringUtils.isNotEmpty(filter)) {
String[] filterValues = StringUtils.split(filter, ",");
List<FieldValue> fieldValues=new ArrayList<>();
for (String filterValue : filterValues) {
FieldValue fieldValue=new FieldValue.Builder().stringValue(filterValue).build();
fieldValues.add(fieldValue);
}
TermsQueryField termsQueryFieldValues=new TermsQueryField.Builder().value(fieldValues).build();
return new TermsQuery.Builder().field(field).terms(termsQueryFieldValues).build();
}
return null;
}
SearchRequest searchRequest=new SearchRequest.Builder().from(query.getFrom()).size(query.getSize()).searchAfter("neuigkeiten").query(qb._toQuery()).sort(getSortOptions(query)).build();
Thanks for any help in advance!
Henriette