Java 类org.elasticsearch.index.query.QueryStringQueryBuilder.Operator 实例源码

项目:uckefu    文件:TopicCommentRepositoryImpl.java   
@Override
public FacetedPage<TopicComment> findByCon(NativeSearchQueryBuilder searchQueryBuilder , String field , String aggname,  String q , final int p , final int ps) {
    FacetedPage<TopicComment> pages  = null ;
    if(!StringUtils.isBlank(q)){
        searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
    }
    SearchQuery searchQuery = searchQueryBuilder.build();
    if(elasticsearchTemplate.indexExists(TopicComment.class)){
        if(!StringUtils.isBlank(q)){
            pages = elasticsearchTemplate.queryForPage(searchQuery, TopicComment.class  , new UKResultMapper());
        }else{
            pages = elasticsearchTemplate.queryForPage(searchQuery, TopicComment.class , new UKAggTopResultExtractor(field , aggname));
        }
    }
    return pages ; 
}
项目:uckefu    文件:UKeFuRepositoryImpl.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public FacetedPage<Serializable> findByCon(Class clazz,NativeSearchQueryBuilder searchQueryBuilder,  String q , final int p , final int ps) {
    FacetedPage<Serializable> pages  = null ;
    if(!StringUtils.isBlank(q)){
        searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
    }
    SearchQuery searchQuery = searchQueryBuilder.build();
    if(elasticsearchTemplate.indexExists(clazz)){
        if(!StringUtils.isBlank(q)){
            pages = elasticsearchTemplate.queryForPage(searchQuery, clazz, new UKResultMapper());
        }else{
            pages = elasticsearchTemplate.queryForPage(searchQuery, clazz , new UKAggTopResultExtractor("userid" , "top"));
        }
    }
    return pages ; 
}
项目:uckefu    文件:TopicRepositoryImpl.java   
@Override
public FacetedPage<Topic> getTopicByCate(String cate , String q, final int p , final int ps) {

    FacetedPage<Topic> pages  = null ;
    NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(termQuery("cate" , cate)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));
    if(!StringUtils.isBlank(q)){
        searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
    }
    searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("title").fragmentSize(200)) ;
    SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps)) ;
    if(elasticsearchTemplate.indexExists(Topic.class)){
        if(!StringUtils.isBlank(q)){
            pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class , new UKResultMapper());
        }else{
            pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class);
        }
    }
    return pages ; 
}
项目:uckefu    文件:TopicRepositoryImpl.java   
@Override
public FacetedPage<Topic> getTopicByCateAndUser(String cate  , String q , String user ,final int p , final int ps) {

    FacetedPage<Topic> pages  = null ;
    NativeSearchQueryBuilder searchQueryBuilder = new NativeSearchQueryBuilder().withQuery(termQuery("cate" , cate)).withQuery(termQuery("creater" , user)).withSort(new FieldSortBuilder("top").unmappedType("boolean").order(SortOrder.DESC)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC));

    if(!StringUtils.isBlank(q)){
        searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
    }
    SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps));
    if(elasticsearchTemplate.indexExists(Topic.class)){

        if(!StringUtils.isBlank(q)){
            pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class, new UKResultMapper());
        }else{
            pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class);
        }
    }
    return pages ; 
}
项目:uckefu    文件:TopicRepositoryImpl.java   
@Override
public FacetedPage<Topic> findByCon(NativeSearchQueryBuilder searchQueryBuilder,  String q , final int p , final int ps) {
    FacetedPage<Topic> pages  = null ;
    if(!StringUtils.isBlank(q)){
        searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
    }
    SearchQuery searchQuery = searchQueryBuilder.build().setPageable(new PageRequest(p, ps));
    if(elasticsearchTemplate.indexExists(Topic.class)){
        if(!StringUtils.isBlank(q)){
            pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class  , new UKResultMapper());
        }else{
            pages = elasticsearchTemplate.queryForPage(searchQuery, Topic.class);
        }
    }
    return pages ; 
}
项目:universal-java-matrix-package    文件:ElasticsearchIndex.java   
public ListMatrix<ElasticsearchSample> search(String query) {
    ListMatrix<ElasticsearchSample> list = new DefaultListMatrix<ElasticsearchSample>();

    QueryBuilder qb = QueryBuilders.queryString(query).defaultOperator(Operator.AND);
    SearchResponse response = client.prepareSearch(index).setNoFields().setTypes(type)
            .setSearchType(SearchType.QUERY_AND_FETCH).setQuery(qb).setFrom(0).setSize(10).setExplain(true)
            .execute().actionGet();

    SearchHit[] results = response.getHits().getHits();

    for (SearchHit hit : results) {
        ElasticsearchSample sample = new ElasticsearchSample(this, hit);
        list.add(sample);
    }

    return list;
}
项目:gazetteer    文件:ElasticSearchPlaceQuery.java   
public ElasticSearchPlaceQuery metaSearch(String query) {
    if(query == null || "".equals(query) || "*".equals(query)) listAll();
    // _id can't be added to _all, so it's appended here, titles are
    // added in order to boost them and prevent their score from being
    // diminished by norms when occurring together with other fields in _all
    else {
        String queryString = "(" + query + ")";
        queryString += " OR _id:\"" + query + "\"";
        if (!query.contains(":")) {
            queryString += " OR prefName.title:\"" + query + "\"^2";
            queryString += " OR names.title:\"" + query + "\"";
        }
        queryBuilder = QueryBuilders.queryString(queryString).defaultField("_all").defaultOperator(Operator.AND);
    }

    return this;

}
项目:uckefu    文件:TopicCommentRepositoryImpl.java   
@Override
public FacetedPage<TopicComment> findByCon(
        NativeSearchQueryBuilder searchQueryBuilder, String q, int p, int ps) {
    searchQueryBuilder.withPageable(new PageRequest(p, ps)).withSort(new FieldSortBuilder("updatetime").unmappedType("date").order(SortOrder.DESC)) ;
    searchQueryBuilder.withHighlightFields(new HighlightBuilder.Field("content").fragmentSize(200)) ;
    if(!StringUtils.isBlank(q)){
        searchQueryBuilder.withQuery(new QueryStringQueryBuilder(q).defaultOperator(Operator.AND)) ;
    }
    return elasticsearchTemplate.queryForPage(searchQueryBuilder.build(), TopicComment.class  , new UKResultMapper()) ;
}
项目:es-service-parent    文件:EsQueryBuilder.java   
public EsQueryBuilder(EsRequest request) {
    this.indexName = request.getIndexname();
    this.request = request;
    String operator = request.getSafeExtend().get("DEFAULT_OPERATOR");
    if (StringUtils.isNotBlank(operator)) {
        default_operator = "and".equals(operator.toLowerCase()) ? Operator.AND : Operator.OR;
    }
}
项目:scaleset-search    文件:DefaultQueryConverter.java   
protected void addQ(SearchRequestBuilder builder, BoolQueryBuilder boolFilter) {
    if (types.length > 0) {
        builder.setTypes(types);
    }
    if (query.getQ() != null && !query.getQ().isEmpty()) {
        boolFilter.must(queryFilter(queryStringQuery(query.getQ()).defaultOperator(Operator.AND)));
    }
}
项目:scaleset-search    文件:DefaultQueryConverter.java   
@Override
public org.elasticsearch.index.query.QueryBuilder query() {
    org.elasticsearch.index.query.QueryBuilder result = null;
    String q = query.getQ();
    if (q != null && !q.isEmpty()) {
        result = queryStringQuery(q).defaultOperator(QueryStringQueryBuilder.Operator.OR);
    }
    return result;
}
项目:scaleset-search    文件:DefaultQueryConverter.java   
protected void addQ(SearchRequestBuilder builder, BoolFilterBuilder boolFilter) {
    if (types.length > 0) {
        builder.setTypes(types);
    }
    if (query.getQ() != null && !query.getQ().isEmpty()) {
        boolFilter.must(queryFilter(queryString(query.getQ()).defaultOperator(Operator.AND)));
    }
}
项目:scaleset-search    文件:DefaultQueryConverter.java   
protected void addQ(DeleteByQueryRequestBuilder builder, BoolFilterBuilder boolFilter) {
    if (types.length > 0) {
        builder.setTypes(types);
    }
    if (query.getQ() != null && !query.getQ().isEmpty()) {
        boolFilter.must(queryFilter(queryString(query.getQ()).defaultOperator(Operator.AND)));
    }
}
项目:scaleset-search    文件:DefaultQueryConverter.java   
@Override
public org.elasticsearch.index.query.QueryBuilder query() {
    org.elasticsearch.index.query.QueryBuilder result = null;
    String q = query.getQ();
    if (q != null && !q.isEmpty()) {
        result = queryString(q).defaultOperator(QueryStringQueryBuilder.Operator.OR);
    }
    return result;
}
项目:universal-java-matrix-package    文件:ElasticsearchIndex.java   
public int count(String string) {
    QueryBuilder query = QueryBuilders.queryString(string).defaultOperator(Operator.AND);
    CountResponse response = client.prepareCount(index).setTypes(type).setQuery(query).execute().actionGet();
    return MathUtil.longToInt(response.getCount());
}