Package org.elasticsearch.client.action.search

Examples of org.elasticsearch.client.action.search.SearchRequestBuilder.addSort()


                }
                try {
                    String indexName = nextIndex();
                    SearchRequestBuilder builder = client.client().prepareSearch(indexName);
                    if (ThreadLocalRandom.current().nextBoolean()) {
                        builder.addSort("num", SortOrder.DESC);
                    } else if (ThreadLocalRandom.current().nextBoolean()) {
                        // add a _score based sorting, won't do any sorting, just to test...
                        builder.addSort("_score", SortOrder.DESC);
                    }
                    if (ThreadLocalRandom.current().nextBoolean()) {
View Full Code Here


                    SearchRequestBuilder builder = client.client().prepareSearch(indexName);
                    if (ThreadLocalRandom.current().nextBoolean()) {
                        builder.addSort("num", SortOrder.DESC);
                    } else if (ThreadLocalRandom.current().nextBoolean()) {
                        // add a _score based sorting, won't do any sorting, just to test...
                        builder.addSort("_score", SortOrder.DESC);
                    }
                    if (ThreadLocalRandom.current().nextBoolean()) {
                        builder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH);
                    }
                    int size = Math.abs(ThreadLocalRandom.current().nextInt()) % numberOfHits;
View Full Code Here

          //get old docs from es
          SearchRequestBuilder searchOptionsOLD = esm.getSearchOptions();
          BoolQueryBuilder boolQueryOLD = QueryBuilders.boolQuery();
          boolQueryOLD.must(QueryBuilders.rangeQuery(DocumentPojo.created_).from(cleanseStartTime));
          boolQueryOLD.must(QueryBuilders.termQuery(DocumentPojo.sourceKey_, sp.getKey()));
          searchOptionsOLD.addSort(DocumentPojo.created_, SortOrder.ASC);
          searchOptionsOLD.setSize(rows);
          SearchResponse rspOLD = esm.doQuery(boolQueryOLD, searchOptionsOLD);
          SearchHit[] docsOLD = rspOLD.getHits().getHits();
         
          //Check all solr docs against mongodb
View Full Code Here

    String[] communityIdStrs = SocialUtils.getCommunityIds(userIdStr, communityIdStrList);
    BaseQueryBuilder queryObj2 = QueryBuilders.boolQuery().should(QueryBuilders.termsQuery(EntityFeaturePojo.communityId_, communityIdStrs));

    BaseQueryBuilder queryObj = QueryBuilders.boolQuery().must(queryObj1).must(queryObj2);

    searchOptions.addSort(EntityFeaturePojo.doccount_, SortOrder.DESC);
    searchOptions.addFields(EntityFeaturePojo.disambiguated_name_, EntityFeaturePojo.doccount_,
        EntityFeaturePojo.type_, EntityFeaturePojo.dimension_);
    if (bIncludeGeo) {
      searchOptions.addFields(EntityFeaturePojo.geotag_);
      searchOptions.addFields(EntityFeaturePojo.ontology_type_);
View Full Code Here

        extraQueryTerms.should(QueryBuilders.queryString(escapedterm).defaultField(field));
        boolQuery.must(extraQueryTerms);
      }//TESTED
      boolQuery.must(QueryBuilders.termsQuery(AssociationFeaturePojo.communityId_, communityIdStrs));

      searchOptions.addSort(AssociationFeaturePojo.doccount_, SortOrder.DESC);

      // Work out which fields to return:
      //TODO (INF-1234) need to work out what to do with quotations and similar here (ie entityX without entityX_index)
      String returnfield;
      boolean bReturningEntities = true;
View Full Code Here

        // Debug code, if rel weight negative then use date to check Lucene score is better...
        if (query.score.relWeight < 0.0) {
          query.score.relWeight = -query.score.relWeight;
        }
        // Set Lucene to order:
        searchSettings.addSort(DocumentPojo.publishedDate_, SortOrder.DESC);
      }//TOTEST
    }//(if docs aren't enabled, don't need to worry about sorting)
   
    // 0.4.2] Prox scoring (needs to happen after [0.3]
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.