我在用index.max_terms_count做实验。我尝试执行一个包含超过65536个术语的术语查询,而且我惊讶地看到它实际上被执行了,因为我阅读了警告这里
使用大量术语执行术语查询请求可能非常慢,因为每个附加项都需要额外的处理和内存。为了防止这种情况,可以直接或通过查找在术语查询中使用的最大术语数仅限于
65536。可以通过索引设置index.max_terms_count来更改特定索引的默认最大值。
为了进一步测试它,我尝试将index.max_terms_count设置为2或3,但它仍然没有按照我预期的方式工作。你能帮我理解我做错了什么吗?
步骤:
curl -X GET http://localhost:9200/twitter/_settings发布于 2022-07-18 07:37:33
在ElasticSearch Version7.0之后,index.max_terms_count的默认值是65536,如果使用默认的max_terms_count设置向terms命令提供超过65536的附加输入的话。例如,65537,它将产生下面的异常消息
{
"error" : {
"root_cause" : [
{
"type" : "query_shard_exception",
"reason" : "failed to create query: The number of terms [65537] used in the Terms Query request has exceeded the allowed maximum of [65536]. This maximum can be set by changing the [index.max_terms_count] index level setting.",
"index" : "my_index",
"index_uuid" : "iJMNOR7znSsmODsG4uArTvQ"
},
....
....
...
}弹性搜索提供了一种将max_terms_count提高到2147483647的方法。为了测试目的,我试着把它设置为2147483647,它运行得很好。
PUT /my-index/_settings
{
"index" : {
"max_terms_count" : 2147483647
}
}但是当我开始将值增加到2147483648时失败了
PUT /my-index/_settings
{
"index" : {
"max_terms_count" : 2147483648
}
}
{
"error" : {
"root_cause" : [
{
"type" : "illegal_argument_exception",
"reason" : "Failed to parse value [2147483648] for setting [index.max_terms_count]"
}
],
"type" : "illegal_argument_exception",
"reason" : "Failed to parse value [2147483648] for setting [index.max_terms_count]",
"caused_by" : {
"type" : "number_format_exception",
"reason" : "For input string: \"2147483648\""
}
},
"status" : 400
}因此,max_terms_count在查询期间确实扮演了一个角色,您的index.max_terms_count基于您的配置(不管是否默认)都具有效果。
https://stackoverflow.com/questions/54520671
复制相似问题