Ive successfully used Elastic 1.x scan and scroll with NEST API to get all documents matching my query. 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)?
Any suggestions are appreciated, Thanks
Scroll
is in 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
I am not a NEST user, but the way that scan and scroll queries are done has changed in ES 2.X. Now, you can do scan and scroll using a simple sort query based on _doc. Please refer to: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
curl -XGET 'localhost:9200/_search?scroll=1m' -d '
{
"sort": [
"_doc"
]
}
'
I hope I am helpful.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.