How to create two alias in elasticsearch, one on hot tier and one on total(or warm, cold) tier?

Viewed 44

I want define two alias, one on hot tier and one on other tier. now, I have one alias and when search for data response time is more than one minutes because first search on hot an then warm and cold and ... . please if you can show me how to do it with example.

Thanks

1 Answers

You can use metadata in your search query. Each document has metadata associated with it, such as the _index and _id metadata fields. Similarly, it stores _tier field.

You can simply add one query in your search context like below:

POST index-alias/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "_tier": {
              "value": "data_hot"
            }
          }
        },
        {
          "term": {
            "field-name": {
              "value": "search-value"
            }
          }
        }
      ]
    }
  }
}

So here I am also searching on _tier field which holds the value data_hot.

Check more about metadata.

Related