我是弹性搜索的新手。成功实现了用于匹配单个字段的搜索文档 API,如下所示:
SearchRequest searchRequest = new SearchRequest(indexName);
//Single field match, only for documentId
QueryBuilder matchQueryBuilder = QueryBuilders.matchQuery("documentId", documentId);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(matchQueryBuilder);
searchRequest.source(sourceBuilder);
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
我想在单个 API 中使用多个字段过滤数据,例如,需要根据以下条件在上述 API 中添加更多过滤器:
documentNumber > 66 && (documentCreatedDate >= date1 && documentCreatedDate <= date2) && documentName like "%test%"
谁能帮助如何在单个 SearchRequest 中应用所有这些过滤器?