search_type=scan removed
The scan search type was deprecated since version 2.1.0 and is now removed. All benefits from this search type can now be achieved by doing a scroll request that sorts documents in _doc order, for instance:
网上流传的老办法不行了。
实际上看,sort不用_doc也OK
代码
using Nest;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
namespace ESScrollReader
{
class Program
{
public static readonly string url = "http://192.168.0.1:9200/";
static void Main(string[] args)
{
ScrollSearch("test_index");
}
public static void ScrollSearch(string index)
{
var settings = new ConnectionSettings(new Uri(url)).DefaultIndex(index);
var client = new ElasticClient(settings);
var searchResponse = client.Search<dynamic>(s => s.Sort(sort => sort.Descending("time")).Size(10000).Scroll("1s"));
while (searchResponse.Documents.Any())
{
searchResponse = client.Scroll<dynamic>("1s", searchResponse.ScrollId);
var d = (Dictionary<string, object>)searchResponse.Documents.First<dynamic>();
//Do sth.
}
}
}
}