别名上的 ElasticSearch 不起作用

标签 elasticsearch alias

我设置了以下别名:

"items": {
    "aliases": {
        "items_0": {
            "filter": {
                "term": {
                    "accountid": "0"
                }
            },
            "index_routing": "0",
            "search_routing": "0"
        }
    }
}

当我在 items 索引中搜索 accountid = 0 的文档时,它会被返回。然而,当我使用 items_0 的索引搜索文档时,它不会被返回。我使用完全相同的搜索条件,只是将索引名称从 items 更改为 items_0。我在这里错过了什么吗?

最佳答案

很可能您没有使用相同的 _routing 索引您的文档值作为您在别名中指定的值。

例如,对于这些文档(其中指定了 _routing):

POST /items/test/_bulk
{"index":{"_id":1,"_routing":0}}
{"accountid": 0}
{"index":{"_id":2,"_routing":0}}
{"accountid": 0}
{"index":{"_id":3,"_routing":0}}
{"accountid": 5}
{"index":{"_id":4,"_routing":0}}
{"accountid": 3}

运行
GET /items_0/_search
{
  "query": {
    "filtered": {
      "filter": {
        "term": {
          "accountid": 0
        }
      }
    }
  }
}

返回正确的结果。因此,您需要确保您的文档已使用 _routing 进行索引。您在别名中使用的 id。

关于别名上的 ElasticSearch 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31195291/

相关文章:

elasticsearch - 在elasticsearch中按嵌套字段List <object>的第一项搜索

ruby-on-rails-3 - Elasticsearch Tire on Rails,返回该年龄段的所有男性,但也返回女性

linux - 如果 bash 别名不能接受参数,为什么这些别名可以工作?

PHP call_user_func 命名空间别名

linux - 在别名中设置变量不起作用

geolocation - 当使用geo_distance过滤器时,ElasticSearch返回的项目太远

search - 在映射中,字段_all指定了index_analyzer时无结果

node.js - Elasticsearch _bulk 更新问题给出 VersionConflictEngineException 消息

android - 在 kotlin 上从 this@ 更改名称

mysql - 删除别名为 MySQL 的子查询