本文整理匯總了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());
}
}
示例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);
}
示例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);
}
示例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);
}