var settings = new ConnectionSettings(Constants.ElasticSearch.Node);
var client = new ElasticClient(settings);
var response = client.Search<DtoTypes.Customer.SearchResult>(s =>
s.From(0)
.Size(100000)
.Query(q => q.MatchAll()));
当大小较小时,它可以工作,但我想检索具有超过100k文档的索引中的所有文档。必须是我缺少的配置设置才能达到限制。我还尝试了Take()
而不是Size()
返回的调试信息是
“无效的低级别呼叫建立的无效NEST响应 POST:/ _search \ r \ n#此API调用的审计跟踪:\ r \ n - BadResponse: 节点:http://127.0.0.1:9200/取消:00:00:00.2964038 \ r \ n#ServerError: ServerError:500Type:search_phase_execution_exception原因:\“all 分片失败\“\ r \ n#OriginalException:System.Net.WebException:The 远程服务器返回错误:(500)内部服务器错误。\ r \ n at System.Net.HttpWebRequest.GetResponse()\ r \ n at Elasticsearch.Net.HttpConnection.Request [TReturn](的RequestData requestData)in C:\用户\拉斯\源\ elasticsearch网\ SRC \ Elasticsearch.Net \连接\ HttpConnection.cs:线 138 \ r \ n#请求:\ r \ n \ r \ n# 响应:\ r \ n \ r \ n“个
答案 0 :(得分:1)
Elasticsearch对其允许返回的结果数量有一个软限制。如果你想要一次性获得超过10.000个结果,你应该使用扫描和滚动功能:)
来自Elasticsearch文档:
“请注意,从+大小不能超过 index.max_result_window索引设置,默认为10,000。看到 Scroll API可以更有效地进行深度滚动。“
参考:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-from-size.html https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html https://nest.azurewebsites.net/nest/search/scroll.html