• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SearchScrollRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.action.search.SearchScrollRequest的典型用法代码示例。如果您正苦于以下问题:Java SearchScrollRequest类的具体用法?Java SearchScrollRequest怎么用?Java SearchScrollRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SearchScrollRequest类属于org.elasticsearch.action.search包,在下文中一共展示了SearchScrollRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: prepareRequest

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
    String scrollId = request.param("scroll_id");
    SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
    searchScrollRequest.scrollId(scrollId);
    String scroll = request.param("scroll");
    if (scroll != null) {
        searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
    }

    request.withContentOrSourceParamParserOrNull(xContentParser -> {
        if (xContentParser != null) {
            // NOTE: if rest request with xcontent body has request parameters, these parameters override xcontent values
            try {
                buildFromContent(xContentParser, searchScrollRequest);
            } catch (IOException e) {
                throw new IllegalArgumentException("Failed to parse request body", e);
            }
        }});
    return channel -> client.searchScroll(searchScrollRequest, new RestStatusToXContentListener<>(channel));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestSearchScrollAction.java


示例2: buildFromContent

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public static void buildFromContent(XContentParser parser, SearchScrollRequest searchScrollRequest) throws IOException {
    if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
        throw new IllegalArgumentException("Malformed content, must start with an object");
    } else {
        XContentParser.Token token;
        String currentFieldName = null;
        while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
            if (token == XContentParser.Token.FIELD_NAME) {
                currentFieldName = parser.currentName();
            } else if ("scroll_id".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
                searchScrollRequest.scrollId(parser.text());
            } else if ("scroll".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
                searchScrollRequest.scroll(new Scroll(TimeValue.parseTimeValue(parser.text(), null, "scroll")));
            } else {
                throw new IllegalArgumentException("Unknown parameter [" + currentFieldName
                        + "] in request body or parameter is of the wrong type[" + token + "] ");
            }
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:21,代码来源:RestSearchScrollAction.java


示例3: handleRequest

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    String scrollId = request.param("scroll_id");
    SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
    searchScrollRequest.scrollId(scrollId);
    String scroll = request.param("scroll");
    if (scroll != null) {
        searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
    }

    if (RestActions.hasBodyContent(request)) {
        XContentType type = XContentFactory.xContentType(RestActions.getRestContent(request));
        if (type == null) {
            if (scrollId == null) {
                scrollId = RestActions.getRestContent(request).toUtf8();
                searchScrollRequest.scrollId(scrollId);
            }
        } else {
            // NOTE: if rest request with xcontent body has request parameters, these parameters override xcontent values
            buildFromContent(RestActions.getRestContent(request), searchScrollRequest);
        }
    }
    client.searchScroll(searchScrollRequest, new RestStatusToXContentListener<SearchResponse>(channel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:25,代码来源:RestSearchScrollAction.java


示例4: buildFromContent

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public static void buildFromContent(BytesReference content, SearchScrollRequest searchScrollRequest) {
    try (XContentParser parser = XContentHelper.createParser(content)) {
        if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
            throw new IllegalArgumentException("Malforrmed content, must start with an object");
        } else {
            XContentParser.Token token;
            String currentFieldName = null;
            while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
                if (token == XContentParser.Token.FIELD_NAME) {
                    currentFieldName = parser.currentName();
                } else if ("scroll_id".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
                    searchScrollRequest.scrollId(parser.text());
                } else if ("scroll".equals(currentFieldName) && token == XContentParser.Token.VALUE_STRING) {
                    searchScrollRequest.scroll(new Scroll(TimeValue.parseTimeValue(parser.text(), null, "scroll")));
                } else {
                    throw new IllegalArgumentException("Unknown parameter [" + currentFieldName + "] in request body or parameter is of the wrong type[" + token + "] ");
                }
            }
        }
    } catch (IOException e) {
        throw new IllegalArgumentException("Failed to parse request body", e);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:24,代码来源:RestSearchScrollAction.java


示例5: doStartNextScroll

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
protected void doStartNextScroll(String scrollId, TimeValue extraKeepAlive, Consumer<? super Response> onResponse) {
    searchWithRetry(listener -> {
        SearchScrollRequest request = new SearchScrollRequest();
        // Add the wait time into the scroll timeout so it won't timeout while we wait for throttling
        request.scrollId(scrollId).scroll(timeValueNanos(firstSearchRequest.scroll().keepAlive().nanos() + extraKeepAlive.nanos()));
        client.searchScroll(request, listener);
    }, r -> consume(r, onResponse));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:ClientScrollableHitSource.java


示例6: testParseSearchScrollRequest

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public void testParseSearchScrollRequest() throws Exception {
    XContentParser content = createParser(XContentFactory.jsonBuilder()
        .startObject()
            .field("scroll_id", "SCROLL_ID")
            .field("scroll", "1m")
        .endObject());

    SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
    RestSearchScrollAction.buildFromContent(content, searchScrollRequest);

    assertThat(searchScrollRequest.scrollId(), equalTo("SCROLL_ID"));
    assertThat(searchScrollRequest.scroll().keepAlive(), equalTo(TimeValue.parseTimeValue("1m", null, "scroll")));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:RestSearchScrollActionTests.java


示例7: testParseSearchScrollRequestWithUnknownParamThrowsException

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public void testParseSearchScrollRequestWithUnknownParamThrowsException() throws Exception {
    SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
    XContentParser invalidContent = createParser(XContentFactory.jsonBuilder()
            .startObject()
                .field("scroll_id", "value_2")
                .field("unknown", "keyword")
            .endObject());

    Exception e = expectThrows(IllegalArgumentException.class,
            () -> RestSearchScrollAction.buildFromContent(invalidContent, searchScrollRequest));
    assertThat(e.getMessage(), startsWith("Unknown parameter [unknown]"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:RestSearchScrollActionTests.java


示例8: ShardFetchRequest

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public ShardFetchRequest(SearchScrollRequest request, long id, IntArrayList list, ScoreDoc lastEmittedDoc) {
    super(request);
    this.id = id;
    this.docIds = list.buffer;
    this.size = list.size();
    this.lastEmittedDoc = lastEmittedDoc;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:8,代码来源:ShardFetchRequest.java


示例9: handleRequest

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    String scrollId = request.param("scroll_id");
    SearchScrollRequest searchScrollRequest = new SearchScrollRequest();
    searchScrollRequest.scrollId(scrollId);
    String scroll = request.param("scroll");
    if (scroll != null) {
        searchScrollRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
    }

    if (RestActions.hasBodyContent(request)) {
        XContentType type = XContentFactory.xContentType(RestActions.getRestContent(request));
        if (type == null) {
            if (scrollId == null) {
                scrollId = RestActions.getRestContent(request).toUtf8();
                searchScrollRequest.scrollId(scrollId);
            }
        } else {
            // NOTE: if rest request with xcontent body has request parameters, these parameters override xcontent values
            RestSearchScrollAction.buildFromContent(RestActions.getRestContent(request), searchScrollRequest);
        }
    }

    final String sparseFormat = request.param("sparse_format", "dict");
    client.searchScroll(searchScrollRequest, new RestBuilderListener<SearchResponse>(channel) {
        @Override
        public RestResponse buildResponse(SearchResponse resp, XContentBuilder builder) throws Exception {
            SearchVectorizeResponse searchVectorizeResponse = new SearchVectorizeResponse(resp);
            searchVectorizeResponse.setFormat(sparseFormat);
            searchVectorizeResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
            return new BytesRestResponse(OK, builder);
        }
    });
}
 
开发者ID:alexksikes,项目名称:elasticsearch-vectorize,代码行数:35,代码来源:RestSearchVectorizeScrollAction.java


示例10: execute

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public void execute(SearchScrollRequest request, final ActionListener<SearchResponse> listener) {
    logger.debug("Search scroll request {}", request);
    try {
        ActionRequestValidationException validation = request.validate();
        if(validation != null && !validation.validationErrors().isEmpty()) {
            throw validation;
        }

        RequestUriBuilder uriBuilder = new RequestUriBuilder()
                .addEndpoint("_search/scroll");

        if (request.scroll() != null) {
            uriBuilder.addQueryParameter("scroll", request.scroll().keepAlive().toString());
        }
        uriBuilder.addQueryParameter("scroll_id", request.scrollId());

        httpClient.getHttpClient().submit(HttpClientRequest.createGet(uriBuilder.toString()))
                .flatMap(ErrorHandler.AS_FUNC)
                .flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<SearchResponse>>() {
                    @Override
                    public Observable<SearchResponse> call(HttpClientResponse<ByteBuf> response) {
                        return response.getContent().flatMap(new Func1<ByteBuf, Observable<SearchResponse>>() {
                            @Override
                            public Observable<SearchResponse> call(ByteBuf byteBuf) {
                                return SearchResponse.parse(byteBuf);
                            }
                        });
                    }
                })
                .single()
                .subscribe(new ListenerCompleterObserver<>(listener));

    } catch (Exception e) {
        listener.onFailure(e);
    }
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:37,代码来源:SearchScrollActionHandler.java


示例11: should_fail_when_scroll_id_is_missing

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Test
public void should_fail_when_scroll_id_is_missing() throws Exception {
    try {
        httpClient.searchScroll(new SearchScrollRequest()).get();
        fail();
    } catch (ExecutionException e) {
        Assertions.assertThat(e).hasCauseInstanceOf(ActionRequestValidationException.class);
        Assertions.assertThat(e.getCause()).hasMessageContaining("scrollId is missing");
    }
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:11,代码来源:SearchScrollActionHandlerTest.java


示例12: execute

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
ActionResponse execute(final ActionRequest request) throws IOException {
    if (request instanceof BulkRequest) {
        return bulk((BulkRequest) request);
    } else if (request instanceof IndexRequest) {
        return index((IndexRequest) request);
    } else if (request instanceof DeleteRequest) {
        return delete((DeleteRequest) request);
    } else if (request instanceof ClearScrollRequest) {
        return clearScroll((ClearScrollRequest) request);
    } else if (request instanceof SearchScrollRequest) {
        return searchScroll((SearchScrollRequest) request);
    }

    return null;
}
 
开发者ID:apache,项目名称:metamodel,代码行数:16,代码来源:ElasticSearchRestClient.java


示例13: InternalScrollSearchRequest

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public InternalScrollSearchRequest(SearchScrollRequest request, long id) {
    this.id = id;
    this.scroll = request.scroll();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:InternalScrollSearchRequest.java


示例14: searchScroll

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
public ActionFuture<SearchResponse> searchScroll(final SearchScrollRequest request) {
    return execute(SearchScrollAction.INSTANCE, request);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java


示例15: InternalScrollSearchRequest

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public InternalScrollSearchRequest(SearchScrollRequest request, long id) {
    super(request);
    this.id = id;
    this.scroll = request.scroll();
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:InternalScrollSearchRequest.java


示例16: searchScroll

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
public ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request) {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:winterstein,项目名称:elasticsearch-java-client,代码行数:6,代码来源:DummyClient.java


示例17: searchScroll

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public void searchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener) {
    searchScrollActionHandler.execute(request, listener);
}
 
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:4,代码来源:HttpClient.java


示例18: scrollSearchResponse

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
protected SearchResponse scrollSearchResponse(final String scrollId) throws IOException {
    return _client.searchScroll(new SearchScrollRequest(scrollId).scroll(
            AbstractElasticSearchDataContext.TIMEOUT_SCROLL));
}
 
开发者ID:apache,项目名称:metamodel,代码行数:6,代码来源:ElasticSearchRestDataSet.java


示例19: SearchScrollRequestBuilder

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
public SearchScrollRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) {
    super(client, new SearchScrollRequest(), jsonToString, stringToJson);
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:4,代码来源:SearchScrollRequestBuilder.java


示例20: doExecute

import org.elasticsearch.action.search.SearchScrollRequest; //导入依赖的package包/类
@Override
protected ActionFuture<SearchResponse> doExecute(SearchScrollRequest request) {
    return client.searchScroll(request);
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:SearchScrollRequestBuilder.java



注:本文中的org.elasticsearch.action.search.SearchScrollRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MessageScope类代码示例发布时间:2022-05-23
下一篇:
Java CompiledVFrame类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap