restHighLevelClient 使用nestedQuery
时间: 2023-05-17 13:03:28 浏览: 92
RestHighLevelClient判断index是否存在
可以使用以下代码实现:
```
QueryBuilder nestedQuery = QueryBuilders.nestedQuery("path.to.nested.field", QueryBuilders.termQuery("path.to.nested.field.keyword", "value"), ScoreMode.None);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(nestedQuery);
SearchRequest searchRequest = new SearchRequest("index_name");
searchRequest.source(searchSourceBuilder);
SearchResponse searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT);
```
阅读全文