我试图从外部来源获取JSON并向其添加一个条件,然后再将其作为查询运行。我知道我可以这样做:
var qb = QueryBuilders.wrapperQuery(json);
var searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(qb);
...但是我想添加必须与此DSL匹配(term:value)
用Java有什么好方法吗?
最佳答案
简单明了:
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
QueryBuilder qb = QueryBuilders.wrapperQuery("");
boolQueryBuilder.must(qb).must(QueryBuilders.termQuery("",""));
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(boolQueryBuilder);