您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch参数allow_no_indices的使用
发布时间:2021-08-23 23:10:22编辑:雪饮阅读()
首先我们看看这样两个请求:
(1)
{
"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": []
}
}
(2)
{
"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": []
}
}
可以看到这两个请求参数不同,但是结果相同,这里用的参数是allow_no_indices=true,其实有关文档已经说明了:
allow_no_indices
如果带有通配符的网址没有索引,这个参数是true值时将防止错误。
那么为什么我们默认没有带这个参数也不会报错(这里这个schools_pri前缀我们的索引列表里面其实是不存在的),就看到一些文档上是不带这个allow_no_indices=true就会报错,那么这里我不带不报错,那么我大胆一个猜想:
{
"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。
关键字词:elasticSearch,allow_no_indices
相关文章
- elasticSearch的expand_wildcards查询
- elasticSearch关闭索引(_close)
- elasticSearch字符串参数ignore_unavailable的用处
- elasticSearch通配符,与-
- elasticSearch通配符*
- elasticSearch的_all查询关键字(在所有索引中查询)
- 完全群集重新启动与滚动升级以及elasticSearch多索引
- elasticSearch安装及配置elasticSearch默认对外端口
- windows下使用elasticSearch-head为elasticSearch进行
- windows下使用elasticSearch-head为elasticSearch创建