Package org.elasticsearch.index.query

Examples of org.elasticsearch.index.query.QueryBuilder


    SearchQueryBuilder() {
    }

    Search.Builder forEmptyQuery(Pageable pageable, List<String> filters) {
        QueryBuilder query = QueryBuilders.boolQuery().should(QueryBuilders.matchAllQuery());

        String search = buildSearch(query, filters, pageable);
        return new Search.Builder(search);
    }
View Full Code Here


        String search = buildSearch(query, filters, pageable);
        return new Search.Builder(search);
    }

    Search.Builder forQuery(String queryTerm, Pageable pageable, List<String> filters) {
        QueryBuilder query = QueryBuilders.multiMatchQuery(queryTerm, BOOSTED_TITLE_FIELD, RAW_CONTENT_FIELD);
        query = QueryBuilders.customScoreQuery(query).script(BOOST_CURRENT_VERSION_SCRIPT);

        String search = buildSearch(query, filters, pageable);
        return new Search.Builder(search);
    }
View Full Code Here

    private void existSomeDocs(final String index, final String source) throws InterruptedException {
        // We wait up to 5 seconds before considering a failing test
        assertThat("Some documents should exist...", awaitBusy(new Predicate<Object>() {
            @Override
            public boolean apply(Object o) {
                QueryBuilder query;
                if (source == null) {
                    query = QueryBuilders.matchAllQuery();
                } else {
                    query = QueryBuilders.queryString(source).defaultField("feedname");
                }
View Full Code Here

  public <P extends ParaObject> List<P> findTermInList(String appid, String type,
      String field, List<?> terms, Pager... pager) {
    if (StringUtils.isBlank(field) || terms == null) {
      return new ArrayList<P>();
    }
    QueryBuilder qb = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
        FilterBuilders.termsFilter(field, terms));
    return searchQuery(appid, type, qb, pager);
  }
View Full Code Here

  public <P extends ParaObject> List<P> findQuery(String appid, String type,
      String query, Pager... pager) {
    if (StringUtils.isBlank(query)) {
      return new ArrayList<P>();
    }
    QueryBuilder qb = QueryBuilders.queryString(query).allowLeadingWildcard(false);
    return searchQuery(appid, type, qb, pager);
  }
View Full Code Here

  public <P extends ParaObject> List<P> findWildcard(String appid, String type,
      String field, String wildcard, Pager... pager) {
    if (StringUtils.isBlank(field) || StringUtils.isBlank(wildcard)) {
      return new ArrayList<P>();
    }
    QueryBuilder qb = QueryBuilders.wildcardQuery(field, wildcard);
    return searchQuery(appid, type, qb, pager);
  }
View Full Code Here

    BoolFilterBuilder tagFilter = FilterBuilders.boolFilter();
    //assuming clean & safe tags here
    for (String tag : tags) {
      tagFilter.must(FilterBuilders.termFilter(Config._TAGS, tag));
    }
    QueryBuilder qb = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), tagFilter);
    // The filter looks like this: ("tag1" OR "tag2" OR "tag3") AND "type"
    return searchQuery(appid, type, qb, pager);
  }
View Full Code Here

      }
    }
    if (noop) {
      return new ArrayList<P>();
    } else {
      QueryBuilder qb = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), fb);
      return searchQuery(appid, type, qb, pager);
    }
  }
View Full Code Here

  public <P extends ParaObject> List<P> findSimilar(String appid, String type, String filterKey,
      String[] fields, String liketext, Pager... pager) {
    if (StringUtils.isBlank(liketext)) {
      return new ArrayList<P>();
    }
    QueryBuilder qb;
    FilterBuilder fb;

    if (fields == null || fields.length == 0) {
      qb = QueryBuilders.moreLikeThisQuery().likeText(liketext).minDocFreq(1).minTermFreq(1);
    } else {
View Full Code Here

  @Override
  public <P extends ParaObject> List<P> findTags(String appid, String keyword, Pager... pager) {
    if (StringUtils.isBlank(keyword)) {
      return new ArrayList<P>();
    }
    QueryBuilder qb = QueryBuilders.wildcardQuery(Utils.type(Tag.class), keyword.concat("*"));
//    SortBuilder sb = SortBuilders.fieldSort("count").order(SortOrder.DESC);
    return searchQuery(appid, Utils.type(Tag.class), qb, pager);
  }
View Full Code Here

TOP

Related Classes of org.elasticsearch.index.query.QueryBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.