【发布时间】:2021-01-13 16:54:14
【问题描述】:
在默认的弹性搜索中,只返回 10k 个结果。但我需要转到超过 10k 个结果的最后一页。
我做了一些尝试,并通过设置 "max_result_window" : 100000 找到了解决方案 我在 Kibana 中执行它,甚至超过 5000 页在此设置后工作正常。
PUT jm-stage-products/_settings
{
"max_result_window" : 100000
}
现在,当我在源代码中创建索引时,我需要包含此设置。但我找不到这样做的方法。 这是我的索引创建功能。我应该如何设置“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";
}
}
【问题讨论】:
标签: elasticsearch .net-core nest