2

I have a question about Elasticsearch.

If I have 2 indices IndexA and IndexB.

I put document docA with id "1" in IndexA, and I put document docB with id "1" in IndexB. The documents are of same doc type but different body (same structure but different values).

What will happen if I create an alias "alias1" which points to both IndexA and IndexB and do a get request of the following?

response = es_client.get(index="alias1", doc_type="doc_type", id="1")

1 Answer 1

2

It is very easy to test, but in short you cannot issue a GET for a document using and alias that points to more than one index !

PUT index1/doc/1
{ "test": 1 }

PUT index2/doc/1
{ "test": 2 }

POST _aliases
{
    "actions" : [
        { "add" : { "index" : "index1", "alias" : "alias1" } },
        { "add" : { "index" : "index2", "alias" : "alias1" } }
    ]
}

GET alias1/doc/1

=>

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "Alias [alias1] has more than one indices associated with it [[index2, index1]], can't execute a single index op"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "Alias [alias1] has more than one indices associated with it [[index2, index1]], can't execute a single index op"
  },
  "status": 400
}
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.