當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchRequestBuilder.setSize方法代碼示例

本文整理匯總了Java中org.elasticsearch.action.search.SearchRequestBuilder.setSize方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchRequestBuilder.setSize方法的具體用法?Java SearchRequestBuilder.setSize怎麽用?Java SearchRequestBuilder.setSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.elasticsearch.action.search.SearchRequestBuilder的用法示例。


在下文中一共展示了SearchRequestBuilder.setSize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: assertStoredBinaryFields

import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
/**
 * Make sure we can load stored binary fields.
 */
void assertStoredBinaryFields(String indexName, Version version) throws Exception {
    SearchRequestBuilder builder = client().prepareSearch(indexName);
    builder.setQuery(QueryBuilders.matchAllQuery());
    builder.setSize(100);
    builder.addStoredField("binary");
    SearchHits hits = builder.get().getHits();
    assertEquals(100, hits.getHits().length);
    for(SearchHit hit : hits) {
        SearchHitField field = hit.field("binary");
        assertNotNull(field);
        Object value = field.getValue();
        assertTrue(value instanceof BytesArray);
        assertEquals(16, ((BytesArray) value).length());
    }
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:OldIndexBackwardsCompatibilityIT.java

示例2: testFromSize

import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
public void testFromSize() throws Exception {
    Builder settings = Settings.builder();
    settings.put(SETTING_NUMBER_OF_SHARDS, 1);
    settings.put(SETTING_NUMBER_OF_REPLICAS, 0);
    assertAcked(prepareCreate("test").setSettings(settings));
    for(int i=0;i<5;i++) {
        client().prepareIndex("test", "type", ""+i).setSource("text", "hello world").get();
    }
    refresh();

    SearchRequestBuilder request = client().prepareSearch();
    request.setQuery(QueryBuilders.termQuery("text", "hello"));
    request.setFrom(1);
    request.setSize(4);
    request.addRescorer(RescoreBuilder.queryRescorer(QueryBuilders.matchAllQuery()), 50);

    assertEquals(4, request.get().getHits().getHits().length);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:19,代碼來源:QueryRescorerIT.java

示例3: fetchAllHits

import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
private List<SearchHit> fetchAllHits(TableInJoinRequestBuilder tableInJoinRequest) {
    Integer hintLimit = tableInJoinRequest.getHintLimit();
    SearchRequestBuilder requestBuilder = tableInJoinRequest.getRequestBuilder();
    if (hintLimit != null && hintLimit < MAX_RESULTS_ON_ONE_FETCH) {
        requestBuilder.setSize(hintLimit);
        SearchResponse searchResponse = requestBuilder.get();
        updateMetaSearchResults(searchResponse);
        return Arrays.asList(searchResponse.getHits().getHits());
    }
    return scrollTillLimit(tableInJoinRequest, hintLimit);
}
 
開發者ID:mazhou,項目名稱:es-sql,代碼行數:12,代碼來源:HashJoinElasticExecutor.java

示例4: configurePaging

import org.elasticsearch.action.search.SearchRequestBuilder; //導入方法依賴的package包/類
private static void configurePaging(UriInfo uriInfo, SearchRequestBuilder searchRequest) {
  int skip = (uriInfo.getSkipOption() == null) ? 0 : uriInfo.getSkipOption().getValue();
  searchRequest.setFrom(skip);

  int top = (uriInfo.getTopOption() == null) ? 20 : uriInfo.getTopOption().getValue();
  searchRequest.setSize(top);
}
 
開發者ID:pukkaone,項目名稱:odata-spring-boot-starter,代碼行數:8,代碼來源:EntityRepository.java


注:本文中的org.elasticsearch.action.search.SearchRequestBuilder.setSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。