Package org.elasticsearch.action.search

Examples of org.elasticsearch.action.search.SearchRequestBuilder


    QueryBuilder qb = QueryBuilders.matchAllQuery();
    FilterBuilder filter = FilterBuilders.termFilter("brand", "heineken");
    FacetBuilder byBrandFacet = null;
    // TODO Create the facet

    SearchRequestBuilder srb = null;
    // TODO Create the request
   
    logger.info("Your query is : {}", srb);

    SearchResponse sr = srb.execute().actionGet();

    // logger.info("Response is : {}", sr);

    Assert.assertNotNull(sr);
    Assert.assertNotNull(sr.getHits());
View Full Code Here


    QueryBuilder qb = QueryBuilders.matchAllQuery();
    FilterBuilder filter = FilterBuilders.termFilter("brand", "heineken");
    FacetBuilder byBrandFacet = null;
    // TODO Create the facet

    SearchRequestBuilder srb = null;
    // TODO Create the request
   
    logger.info("Your query is : {}", srb);

    SearchResponse sr = srb.execute().actionGet();

    // logger.info("Response is : {}", sr);

    Assert.assertNotNull(sr);
    Assert.assertNotNull(sr.getHits());
View Full Code Here

  public void brand_rangeFacet_matchAllQuery() throws Exception {
    QueryBuilder qb = QueryBuilders.matchAllQuery();
    FacetBuilder byPriceFacet = null;
    // TODO Create the facet

    SearchRequestBuilder srb = null;
    // TODO Create the request
   
    logger.info("Your query is : {}", srb);

    SearchResponse sr = srb.execute().actionGet();

    logger.info("Response is : {}", sr);

    Assert.assertNotNull(sr);
    Assert.assertNotNull(sr.getHits());
View Full Code Here

   * <br>see http://www.elasticsearch.org/guide/reference/api/multi-search.html
   */
  @Test
  public void multi_Search() throws Exception {
    // TODO Prepare the first query (queryString with "pale"). We want only one result
    SearchRequestBuilder srb1 = null;
    logger.info("Your 1st query is : {}", srb1);
   
    // TODO Prepare the second query (matchQuery on "brand" with "HEINEKEN"). We want only one result
    SearchRequestBuilder srb2 = null;
    logger.info("Your 2nd query is : {}", srb2);
   
    // TODO Call the Multisearch API and add the two queries
    MultiSearchResponse sr = null;

View Full Code Here

        scanThis(any, QueryBuilders.matchAllQuery(), keepTimeInMinutes, pageSize);
    }

    public void scanThis(AnyExecutor<T> any, QueryBuilder query,
            long keepTimeInMinutes, int pageSize) {
        SearchRequestBuilder srb = client.prepareSearch(getIndexName()).
                setQuery(query).setSize(pageSize).
                setSearchType(SearchType.SCAN).
                setScroll(TimeValue.timeValueMinutes(keepTimeInMinutes));
        SearchResponse rsp = srb.execute().actionGet();

        try {
            int counter = 0;
            while (true) {
                rsp = client.prepareSearchScroll(rsp.scrollId()).
View Full Code Here

        str += rsp.getNodesMap().keySet();
        logger.info(str);
    }
   
    public SearchResponse query(QueryBuilder queryBuilder) {
        SearchRequestBuilder srb = createSearchBuilder();
        srb.setQuery(queryBuilder);
        return srb.execute().actionGet();
    }
View Full Code Here

    public SearchResponse query(JetwickQuery query) {
        return query(query, false, false);
    }

    public SearchResponse query(JetwickQuery query, boolean log, boolean explain) {
        SearchRequestBuilder srb = createSearchBuilder();
        srb.setExplain(query.isExplain());
        query.initRequestBuilder(srb);
        if (log)
            try {
                logger.info(srb.internalBuilder().toXContent(JsonXContent.contentBuilder(), null).string());
            } catch (Exception ex) {
            }
        return srb.execute().actionGet();
    }
View Full Code Here

        return user;
    }

    SearchResponse prepareFindBy(String key, Object value) {
        SearchRequestBuilder srb = createSearchBuilder();
        // fastest method. we only expect one or two objects
        srb.setSearchType(SearchType.QUERY_AND_FETCH);
        srb.setQuery(QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(),
                FilterBuilders.termFilter(key, value)));
        return srb.execute().actionGet();
    }
View Full Code Here

        }
    }

    public Collection<JUser> findByTopic(String topic, int size) {
        try {
            SearchRequestBuilder srb = createSearchBuilder();
            srb.addSort(LAST_VISIT_DT, SortOrder.DESC);
            srb.setQuery(QueryBuilders.queryString(topic).defaultOperator(Operator.AND).defaultField(TOPICS + ".name").
                    allowLeadingWildcard(false).useDisMax(true));
            srb.setSize(size);
            SearchResponse rsp = srb.execute().actionGet();
            logger.info("[user.findByTopic] took:" + rsp.getTookInMillis() / 1000f + " topic:" + topic + " hits:" + rsp.getHits().totalHits());
            List<JUser> list = collectObjects(rsp);
            Collections.shuffle(list);
            return list;
        } catch (Exception ex) {
View Full Code Here

            return Collections.emptyList();
        }
    }

    public Collection<String> getQueryTerms() {
        SearchRequestBuilder srb = createSearchBuilder();
        FilteredQueryBuilder fb = QueryBuilders.filteredQuery(
                QueryBuilders.matchAllQuery(), FilterBuilders.existsFilter(TOKEN));

        srb.addFacet(FacetBuilders.termsFacet(QUERY_TERMS).field(QUERY_TERMS).size(1000)).
                setQuery(fb);
        SearchResponse rsp = srb.execute().actionGet();
//        SearchResponse rsp = search(new UserQuery().addFacetField(QUERY_TERMS, 1000));
        TermsFacet tf = (TermsFacet) rsp.getFacets().facet(QUERY_TERMS);
        if (tf.entries() != null && !tf.entries().isEmpty()) {
            Collection<String> res = new ArrayList<String>();
            for (TermsFacet.Entry cnt : tf.entries()) {
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.search.SearchRequestBuilder

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.