当前位置: 首页>>代码示例>>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;未经允许,请勿转载。