查询java客户端

时间:2017-03-23 07:57:22

标签: elasticsearch

我正在尝试使用QueryBuilders构建此json,但是"查询" json缺少关键,有人可以帮帮我吗?

{
    "query": {
        "bool": {
            "disable_coord": false,
            "adjust_pure_negative": true,
            "boost": 1.0
        }
    }
}

1 个答案:

答案 0 :(得分:0)

对于query换行,您可以将SearchSourceBuilderQueryBuilder一起使用,也可以像:

BoolQueryBuilder must = boolQuery().adjustPureNegative(true).disableCoord(false).boost(1.0f)
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(must);
XContentBuilder xContentBuilder = jsonBuilder();
searchSourceBuilder.toXContent(xContentBuilder, ToXContent.EMPTY_PARAMS);
System.out.println(xContentBuilder.string());