最近想做一个通用的java ES查询接口,由于ES查询语句种类比较多,使用TransportClient需要设置太多参数,请问一下TransportClient 支持将整个ES查询语句作为参数 进行查询操作吗?
当前TransportClient使用方法如下:
QueryStringQueryBuilder qsqb = QueryBuilders.queryStringQuery(syntax);
qsqb.defaultOperator(Operator.AND);
qsqb.defaultField("_all");
SearchRequestBuilder requestBuilder = client.prepareSearch(indices)
.setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(qsqb)
.setFrom(start).setSize(rows).setExplain(false);
SearchResponse response = requestBuilder.execute().actionGet();
当前TransportClient使用方法如下:
QueryStringQueryBuilder qsqb = QueryBuilders.queryStringQuery(syntax);
qsqb.defaultOperator(Operator.AND);
qsqb.defaultField("_all");
SearchRequestBuilder requestBuilder = client.prepareSearch(indices)
.setSearchType(SearchType.QUERY_THEN_FETCH).setQuery(qsqb)
.setFrom(start).setSize(rows).setExplain(false);
SearchResponse response = requestBuilder.execute().actionGet();
1 个回复
kennywu76 - Wood
赞同来自: elisha