Java 类org.elasticsearch.index.query.BaseQueryBuilder 实例源码

项目:elasticsql    文件:QueryMaker.java   
private void explanWhere(BoolQueryBuilder boolQuery, Where where) throws SqlParseException {
    while (where.getWheres().size() == 1) {
        where = where.getWheres().getFirst();
    }
    if (where instanceof Condition) {
        addSubQuery(boolQuery, where, (BaseQueryBuilder) make((Condition) where));
    } else {
        BoolQueryBuilder subQuery = QueryBuilders.boolQuery();
        addSubQuery(boolQuery, where, subQuery);
        for (Where subWhere : where.getWheres()) {
            explanWhere(subQuery, subWhere);
        }
    }
}
项目:elasticsql    文件:QueryMaker.java   
/**
 * 增加嵌套插
 * 
 * @param boolQuery
 * @param where
 * @param subQuery
 */
private void addSubQuery(BoolQueryBuilder boolQuery, Where where, BaseQueryBuilder subQuery) {
    if (where.getConn() == CONN.AND) {
        boolQuery.must(subQuery);
    } else {
        boolQuery.should(subQuery);
    }
}
项目:NeverwinterDP-Commons    文件:ESObjectClient.java   
public SearchResponse search(BaseQueryBuilder xqb, boolean explain, int from, int to) throws ElasticsearchException {
  SearchResponse response =
      esclient.client.prepareSearch(index).setSearchType(SearchType.QUERY_THEN_FETCH).
          setQuery(xqb).
          setFrom(from).setSize(to).
          setExplain(explain).
          execute().actionGet();
  return response;
}
项目:NeverwinterDP-Commons    文件:ESObjectClient.java   
public long count(BaseQueryBuilder xqb) throws Exception {
  CountResponse response =
      esclient.client.prepareCount(index).
          setQuery(xqb).
          execute().actionGet();
  return response.getCount();
}
项目:NeverwinterDP-Commons    文件:ESObjectClient.java   
public SearchResponse search(BaseQueryBuilder xqb) throws ElasticsearchException {
  return search(xqb, false, 0, 100);
}
项目:NeverwinterDP-Commons    文件:ESObjectClient.java   
public SearchResponse search(BaseQueryBuilder xqb, int from, int to) throws ElasticsearchException {
  return search(xqb, false, from, to);
}