简体   繁体   English

在Elasticsearch Nest 5.5中使用.Scroll时遇到问题

[英]Having problems with using .Scroll in Elasticsearch Nest 5.5

I wanted to loop and scroll thru the data using the scrollid then I've upgraded to NEST 5.5 and trying to remediate this block of code: 我想使用scrollid循环并滚动数据,然后升级到NEST 5.5并尝试修复此代码块:

scrollGetSearch = client.Raw.ScrollGet(scrollId, x => x
    .AddQueryString("scroll", "1m")
    .AddQueryString("size", "1000"));

Tried using using .Scroll but can't find the correct arguments for the scroll method: 使用.Scroll尝试过,但找不到scroll方法的正确参数:

scrollGetSearch = client.Scroll("1m",scrollId)

Getting the Error 得到错误

The type arguments for method 'Nest.ElasticClient.Scroll(Nest.Time, string, System.Func,Nest.IScrollRequest>)' cannot be inferred from the usage. 无法从用法中推断出方法'Nest.ElasticClient.Scroll(Nest.Time,string,System.Func,Nest.IScrollRequest>)'的类型参数。 Try specifying the type arguments explicitly. 尝试显式指定类型参数。

Your first request uses the low level client, Elasticsearch.Net, whilst the second request uses the high level client. 您的第一个请求使用低级客户端Elasticsearch.Net,而第二个请求使用高级客户端。

To perform the same low level request in NEST 5.x would be 要在NEST 5.x中执行相同的低级别请求,将是

ElasticsearchResponse<T> lowLevelScrollResponse = client.LowLevel.ScrollGet<T>(x => x
    .AddQueryString("scroll_id", scrollId)
    .AddQueryString("scroll", "1m"));

The generic parameter T should be the type that the body of the response should be deserialized into eg string , byte[] or because you're using the low level client exposed on the high level client, the high level response, SearchResponse<TDocument> , where TDocument is the type that each _source should be deserialized into. 通用参数T应该是将响应主体反序列化为例如stringbyte[]或者因为您使用的是暴露在高级客户端上的低级客户端,所以高级响应SearchResponse<TDocument> ,其中TDocument是每个_source应该反序列化为的类型。 There's no need to specify size on a scroll request as the size is configured on the first scroll call to _search endpoint. 无需在滚动请求中指定size ,因为在对_search端点的第一个滚动调用中已配置了大小。

To perform the same search with the high level client 与高级客户端执行相同的搜索

ISearchResponse<T> scrollResponse = client.Scroll<T>("1m", scrollId);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM