您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch参数ignore_unavailable与allow_no_indices的区别
发布时间:2021-08-23 23:37:29编辑:雪饮阅读()
上篇有了解了docxignore_unavailable是为了匹配查询带有通配符的网址没有索引,这个参数是true值时将防止错误。
像是下面这样:
http://localhost:9200/schools_pri*/_search?allow_no_indices=true post
{
"query":{
"match_all":{}
}
}
响应:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 0,
"successful": 0,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": 0.0,
"hits": []
}
}
那么我们将这个通配符查询设定一个固定的索引再去查询,再来看看如何
那么修改后如:
http://localhost:9200/schools_pri/_search?allow_no_indices=true post
{
"query":{
"match_all":{}
}
}:
响应:
{
"error": {
"root_cause": [
{
"type": "index_not_found_exception",
"reason": "no such index [schools_pri]",
"resource.type": "index_or_alias",
"resource.id": "schools_pri",
"index_uuid": "_na_",
"index": "schools_pri"
}
],
"type": "index_not_found_exception",
"reason": "no such index [schools_pri]",
"resource.type": "index_or_alias",
"resource.id": "schools_pri",
"index_uuid": "_na_",
"index": "schools_pri"
},
"status": 404
}
看来是报错了呢,那么也就是说allow_no_indices只对使用通配符进行查询的时候没有查到相关索引的时候防止报错。
那么前面我们也了解到了ignore_unavailable 用于:
如果URL中存在的一个或多个索引不存在,则不会发生错误或操作不会停止。
那么这两个参数他们之间有什么区别呢?
且看这个请求:
http://localhost:9200/schools_pri*/_search?allow_no_indices=false&ignore_unavailable=true post
{
"query":{
"match_all":{}
}
}
响应:
{
"error": {
"root_cause": [
{
"type": "index_not_found_exception",
"reason": "no such index [schools_pri*]",
"resource.type": "index_or_alias",
"resource.id": "schools_pri*",
"index_uuid": "_na_",
"index": "schools_pri*"
}
],
"type": "index_not_found_exception",
"reason": "no such index [schools_pri*]",
"resource.type": "index_or_alias",
"resource.id": "schools_pri*",
"index_uuid": "_na_",
"index": "schools_pri*"
},
"status": 404
}
这里虽然是报错了,但是就我怀疑是默认情况下allow_no_indices=true,这里请求又用的正好是通配符,那么要测试ignore_unavailable为true就要结合allow_no_indices=false,但是这里并没有如预料的显示成功。
那么我觉得应该是优先级问题,或者说这种情况本身就是如此,但是我更相信这样一种网上这样的一种说法:
ignore_unavailable控制的是任何索引包括带通配符和不带通配符的,
allow_no_indices 控制的是带通配符的索引。
可能在低版本上才可能可以进行有力的实践证据的产生。
另外我怀疑这两个参数在未来可能还会发生happened变动,也是有可能的。
关键字词:elasticSearch,ignore_unavailable,allow_no_indices
相关文章
- elasticSearch参数allow_no_indices的使用
- elasticSearch的expand_wildcards查询
- elasticSearch关闭索引(_close)
- elasticSearch字符串参数ignore_unavailable的用处
- elasticSearch通配符,与-
- elasticSearch通配符*
- elasticSearch的_all查询关键字(在所有索引中查询)
- 完全群集重新启动与滚动升级以及elasticSearch多索引
- elasticSearch安装及配置elasticSearch默认对外端口
- windows下使用elasticSearch-head为elasticSearch进行