[英]ElasticSearch query using NEST 2.x with scroll is not returning result
I'm trying to retrieve all data from the elasticsearch based on a message occurrence, i figured that if i used Scroll i could loop until the document search end but the following query returns Documents = 0 but Total = 1954: 我正在尝试根据出现的消息从elasticsearch检索所有数据,我发现如果使用Scroll,我可以循环直到文档搜索结束,但以下查询返回Documents = 0但Total = 1954:
var response = client.Search<Log4Net>(s => s
.Query(q => q.QueryString(qs => qs
.DefaultField(m => m.Message).Query("\"" + message + "\"")))
.SearchType(SearchType.Scan)
.Scroll("60s"));
while (response.Documents.Any())
{
var request = new BulkRequest();
request.Refresh = true;
request.Consistency = Consistency.One;
request.Operations = new List<IBulkOperation>();
foreach (var item in response.Documents)
{
request.Operations.Add(new BulkIndexOperation<Log4Net>(item));
}
var result = client.Bulk(request);
response = client.Scroll<Log4Net>("60s", response.ScrollId);
}
the response.Document is coming empty if i use the scroll, if i remove and get the first 1000 messages i can get the data, is anything wrong with how i'm using the Scroll? 如果我使用滚动条,则文档将为空,如果我删除并获得前1000条消息,则可以获取数据,我使用滚动条的方式有什么问题吗?
If you specify .SearchType(SearchType.Scan)
, the first response doesn't contain any documents; 如果指定.SearchType(SearchType.Scan)
,则第一个响应不包含任何文档。 It will give you the total documents in the .Total
property that will be returned by scrolling using the .ScrollId
on the response in a scroll request. 它将为您提供.Total
属性中的全部文档,该属性将通过在滚动请求中使用响应上的.ScrollId
滚动来返回。
If you don't specify .SearchType(SearchType.Scan)
, the first response will contain the first set of documents. 如果未指定 .SearchType(SearchType.Scan)
,则第一个响应将包含第一组文档。
This is a difference in Elasticsearch and not NEST. 这是Elasticsearch的差异,不是NEST。 SearchType.Scan
is actually deprecated in 2.1.0 , but is still in NEST 2.x as it supports all minor versions of Elasticsearch 2.x. SearchType.Scan
实际上在2.1.0中已弃用 ,但仍在NEST 2.x中,因为它支持Elasticsearch 2.x的所有次要版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.