本文整理汇总了Java中org.elasticsearch.action.search.SearchRequest.scroll方法的典型用法代码示例。如果您正苦于以下问题:Java SearchRequest.scroll方法的具体用法?Java SearchRequest.scroll怎么用?Java SearchRequest.scroll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.action.search.SearchRequest
的用法示例。
在下文中一共展示了SearchRequest.scroll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
@Before
@Override
public void setUp() throws Exception {
super.setUp();
final ExecutorService directExecutor = EsExecutors.newDirectExecutorService();
threadPool = new TestThreadPool(getTestName()) {
@Override
public ExecutorService executor(String name) {
return directExecutor;
}
@Override
public ScheduledFuture<?> schedule(TimeValue delay, String name, Runnable command) {
command.run();
return null;
}
};
retries = 0;
searchRequest = new SearchRequest();
searchRequest.scroll(timeValueMinutes(5));
searchRequest.source(new SearchSourceBuilder().size(10).version(true).sort("_doc").size(123));
retriesAllowed = 0;
}
示例2: testInitialSearchParamsMisc
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
public void testInitialSearchParamsMisc() {
SearchRequest searchRequest = new SearchRequest().source(new SearchSourceBuilder());
Version remoteVersion = Version.fromId(between(0, Version.CURRENT.id));
TimeValue scroll = null;
if (randomBoolean()) {
scroll = TimeValue.parseTimeValue(randomPositiveTimeValue(), "test");
searchRequest.scroll(scroll);
}
int size = between(0, Integer.MAX_VALUE);
searchRequest.source().size(size);
Boolean fetchVersion = null;
if (randomBoolean()) {
fetchVersion = randomBoolean();
searchRequest.source().version(fetchVersion);
}
Map<String, String> params = initialSearchParams(searchRequest, remoteVersion);
assertThat(params, scroll == null ? not(hasKey("scroll")) : hasEntry("scroll", scroll.toString()));
assertThat(params, hasEntry("size", Integer.toString(size)));
assertThat(params, fetchVersion == null || fetchVersion == true ? hasEntry("version", null) : not(hasEntry("version", null)));
}
示例3: randomSearchRequest
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
/**
* Build a random search request.
*
* @param randomSearchSourceBuilder builds a random {@link SearchSourceBuilder}. You can use
* {@link #randomSearchSourceBuilder(Supplier, Supplier, Supplier, Supplier, Supplier)}.
*/
public static SearchRequest randomSearchRequest(Supplier<SearchSourceBuilder> randomSearchSourceBuilder) throws IOException {
SearchRequest searchRequest = new SearchRequest();
if (randomBoolean()) {
searchRequest.indices(generateRandomStringArray(10, 10, false, false));
}
if (randomBoolean()) {
searchRequest.indicesOptions(IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()));
}
if (randomBoolean()) {
searchRequest.types(generateRandomStringArray(10, 10, false, false));
}
if (randomBoolean()) {
searchRequest.preference(randomAsciiOfLengthBetween(3, 10));
}
if (randomBoolean()) {
searchRequest.requestCache(randomBoolean());
}
if (randomBoolean()) {
searchRequest.routing(randomAsciiOfLengthBetween(3, 10));
}
if (randomBoolean()) {
searchRequest.scroll(randomPositiveTimeValue());
}
if (randomBoolean()) {
searchRequest.searchType(randomFrom(SearchType.values()));
}
if (randomBoolean()) {
searchRequest.source(randomSearchSourceBuilder.get());
}
return searchRequest;
}
示例4: ShardSearchLocalRequest
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
ShardSearchLocalRequest(SearchRequest searchRequest, ShardId shardId, int numberOfShards,
AliasFilter aliasFilter, float indexBoost, long nowInMillis) {
this(shardId, numberOfShards, searchRequest.searchType(),
searchRequest.source(), searchRequest.types(), searchRequest.requestCache(), aliasFilter, indexBoost);
this.scroll = searchRequest.scroll();
this.nowInMillis = nowInMillis;
}
示例5: parseSearchRequest
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
/**
* Parses the rest request on top of the SearchRequest, preserving values that are not overridden by the rest request.
*
* @param requestContentParser body of the request to read. This method does not attempt to read the body from the {@code request}
* parameter
*/
public static void parseSearchRequest(SearchRequest searchRequest, RestRequest request,
XContentParser requestContentParser) throws IOException {
if (searchRequest.source() == null) {
searchRequest.source(new SearchSourceBuilder());
}
searchRequest.indices(Strings.splitStringByCommaToArray(request.param("index")));
if (requestContentParser != null) {
QueryParseContext context = new QueryParseContext(requestContentParser);
searchRequest.source().parseXContent(context);
}
final int batchedReduceSize = request.paramAsInt("batched_reduce_size", searchRequest.getBatchedReduceSize());
searchRequest.setBatchedReduceSize(batchedReduceSize);
// do not allow 'query_and_fetch' or 'dfs_query_and_fetch' search types
// from the REST layer. these modes are an internal optimization and should
// not be specified explicitly by the user.
String searchType = request.param("search_type");
if ("query_and_fetch".equals(searchType) ||
"dfs_query_and_fetch".equals(searchType)) {
throw new IllegalArgumentException("Unsupported search type [" + searchType + "]");
} else {
searchRequest.searchType(searchType);
}
parseSearchSource(searchRequest.source(), request);
searchRequest.requestCache(request.paramAsBoolean("request_cache", null));
String scroll = request.param("scroll");
if (scroll != null) {
searchRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
}
searchRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
searchRequest.routing(request.param("routing"));
searchRequest.preference(request.param("preference"));
searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions()));
}
示例6: AbstractBulkByScrollRequest
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
/**
* Constructor for actual use.
*
* @param searchRequest the search request to execute to get the documents to process
* @param setDefaults should this request set the defaults on the search request? Usually set to true but leave it false to support
* request slicing
*/
public AbstractBulkByScrollRequest(SearchRequest searchRequest, boolean setDefaults) {
this.searchRequest = searchRequest;
// Set the defaults which differ from SearchRequest's defaults.
if (setDefaults) {
searchRequest.scroll(DEFAULT_SCROLL_TIMEOUT);
searchRequest.source(new SearchSourceBuilder());
searchRequest.source().size(DEFAULT_SCROLL_SIZE);
}
}
示例7: copyRequest
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
private static SearchRequest copyRequest(SearchRequest searchRequest) throws IOException {
SearchRequest result = new SearchRequest();
result.indices(searchRequest.indices());
result.indicesOptions(searchRequest.indicesOptions());
result.types(searchRequest.types());
result.searchType(searchRequest.searchType());
result.preference(searchRequest.preference());
result.routing(searchRequest.routing());
result.requestCache(searchRequest.requestCache());
result.scroll(searchRequest.scroll());
if (searchRequest.source() != null) {
result.source(searchRequest.source());
}
return result;
}
示例8: getLastEmittedDocPerShard
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
public ScoreDoc[] getLastEmittedDocPerShard(SearchRequest request, ScoreDoc[] sortedShardList, int numShards) {
if (request.scroll() != null) {
return getLastEmittedDocPerShard(sortedShardList, numShards);
} else {
return null;
}
}
示例9: ShardSearchLocalRequest
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
ShardSearchLocalRequest(SearchRequest searchRequest, ShardRouting shardRouting, int numberOfShards,
String[] filteringAliases, long nowInMillis) {
this(shardRouting.shardId(), numberOfShards, searchRequest.searchType(),
searchRequest.source(), searchRequest.types(), searchRequest.requestCache());
this.extraSource = searchRequest.extraSource();
this.templateSource = searchRequest.templateSource();
this.template = searchRequest.template();
this.scroll = searchRequest.scroll();
this.filteringAliases = filteringAliases;
this.nowInMillis = nowInMillis;
copyContextAndHeadersFrom(searchRequest);
}
示例10: parseSearchRequest
import org.elasticsearch.action.search.SearchRequest; //导入方法依赖的package包/类
public static void parseSearchRequest(SearchRequest searchRequest, RestRequest request, ParseFieldMatcher parseFieldMatcher,
BytesReference bodyContent) {
searchRequest.indices(Strings.splitStringByCommaToArray(request.param("index")));
// get the content, and put it in the body
// add content/source as template if template flag is set
boolean isTemplateRequest = request.path().endsWith("/template");
if (bodyContent == null) {
if (RestActions.hasBodyContent(request)) {
bodyContent = RestActions.getRestContent(request);
}
}
if (bodyContent != null) {
if (isTemplateRequest) {
searchRequest.templateSource(bodyContent);
} else {
searchRequest.source(bodyContent);
}
}
// do not allow 'query_and_fetch' or 'dfs_query_and_fetch' search types
// from the REST layer. these modes are an internal optimization and should
// not be specified explicitly by the user.
String searchType = request.param("search_type");
if (SearchType.fromString(searchType, parseFieldMatcher).equals(SearchType.QUERY_AND_FETCH) ||
SearchType.fromString(searchType, parseFieldMatcher).equals(SearchType.DFS_QUERY_AND_FETCH)) {
throw new IllegalArgumentException("Unsupported search type [" + searchType + "]");
} else {
searchRequest.searchType(searchType);
}
searchRequest.extraSource(parseSearchSource(request));
searchRequest.requestCache(request.paramAsBoolean("request_cache", null));
String scroll = request.param("scroll");
if (scroll != null) {
searchRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
}
searchRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
searchRequest.routing(request.param("routing"));
searchRequest.preference(request.param("preference"));
searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions()));
}