Isa*_*ala 0 elasticsearch nest .net-core
默认情况下,elasticsearch 仅返回 10k 结果。但我需要转到超过 10k 结果的最后一页。
我做了一些工作,并通过设置“max_result_window”找到了一个解决方案:100000 我在 Kibana 中执行它,甚至超过 5000 页在此设置后工作正常。
PUT jm-stage-products/_settings
{
"max_result_window" : 100000
}
Run Code Online (Sandbox Code Playgroud)
现在,当我在源代码中创建索引时,我需要包含此设置。但我找不到方法来做到这一点。这是我的索引创建函数。我应该如何设置“max_result_window”:100000?
public string InitIndexing()
{
var indexName = string.Format(_config.ElasticIndexName, _config.HostingEnvironment);
//-----------------------------------------------------------
if (!_client.Indices.Exists(indexName).Exists)
{
//----------------------------------------------
var indexSettings = new IndexSettings
{
NumberOfReplicas = 0, // If this is set to 1 or more, then the index becomes yellow.
NumberOfShards = 5,
};
var indexConfig = new IndexState
{
Settings = indexSettings
};
var createIndexResponses = _client.Indices.Create(indexName, c => c
.InitializeUsing(indexConfig)
.Map<ElasticIndexGroupProduct>(m => m.AutoMap())
);
return createIndexResponses.DebugInformation;
}
else
{
return $"{_config.ElasticIndexName} already exists";
}
}
Run Code Online (Sandbox Code Playgroud)
max_result_window您可以使用以下代码片段设置创建索引:
var createIndexResponse = await elasticClient.Indices.CreateAsync("index_name", c => c
.Settings(s => s
.Setting(UpdatableIndexSettings.MaxResultWindow, 100000)))
Run Code Online (Sandbox Code Playgroud)
已经存在的索引可以使用以下流畅的语法进行更新:
await elasticClient.Indices.UpdateSettingsAsync("index_name", s => s
.IndexSettings(i => i.Setting(UpdatableIndexSettings.MaxResultWindow, 100000)));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4084 次 |
| 最近记录: |