How to request a single document by _id via alias?

后端 未结 4 1441
失恋的感觉
失恋的感觉 2021-01-11 20:36

Is it possible to request a single document by its id by querying an alias, provided that all keys across all indices in the alias are unique (it is an external guarantee)?<

4条回答
  •  悲&欢浪女
    2021-01-11 21:18

    Yes, querying an alias spanning over multiple indices work the same way as querying one indice.

    Just do this query over the alias:

    POST my_alias_name/_search
    {
        "filter":{
            "term":{"_id": "AUwNrOZsm6BwwrmnodbW"}
        }
    }
    

    EDIT: GET operations are not real searches and can't be done on aliases spanning over multiple indexes. So the following query is in fact no permitted:

    GET my_alias_name/my_type/AUwNrOZsm6BwwrmnodbW
    

提交回复
热议问题