[英]Scan and Scroll Substitute in ElasticSearch version 2.x (NEST C#)
Ive successfully used Elastic 1.x scan and scroll with NEST API to get all documents matching my query. Ive已成功使用Elastic 1.x扫描和 NEST API 滚动来获取与我的查询匹配的所有文档。 Started a new project and thought Ill use newest Elastic version 2.x, and stumbled on the first hurdle - how do I return all documents matching query (in c# using NEST)? 开始一个新项目,以为我会使用最新的Elastic版本2.x,并偶然发现第一个障碍-如何返回所有与查询匹配的文档(在C#中使用NEST)?
Any suggestions are appreciated, Thanks 任何建议表示赞赏,谢谢
Scroll
is in Elasticsearch 2.x Scroll
在Elasticsearch 2.x中
synchronous version 同步版本
var response = client.Search<object>(s => s
// specify a scroll time of 2 minutes using string,
// implicitly converts to Time type
.Scroll("2m")
.Sort(ss => ss
// sorting on "_doc"
.Ascending(SortSpecialField.DocumentIndexOrder)
)
);
asynchronous version 异步版本
var response = await client.SearchAsync<object>(s => s
// specify a scroll time of 2 minutes using Time type
.Scroll(new Time(2, Nest.TimeUnit.Minute))
.Sort(ss => ss
// sorting on "_doc"
.Ascending(SortSpecialField.DocumentIndexOrder)
)
);
More information on the Time
units 有关Time
单位的更多信息
I am not a NEST user, but the way that scan and scroll queries are done has changed in ES 2.X. 我不是NEST用户,但是在ES 2.X中更改了扫描和滚动查询的方式。 Now, you can do scan and scroll using a simple sort query based on _doc. 现在,您可以使用基于_doc的简单排序查询进行扫描和滚动。 Please refer to: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html 请参考: https : //www.elastic.co/guide/zh-CN/elasticsearch/reference/current/search-request-scroll.html
curl -XGET 'localhost:9200/_search?scroll=1m' -d '
{
"sort": [
"_doc"
]
}
'
I hope I am helpful. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.