Storing and retrieving the index name

(Patrick) #1

Is there a way to store the index name in the documents?

I have created an alias to search across three indexes. And, in some cases I would like to specify the index without changing the main api call.

I have updated the mappings for the index using:
"tweet" : {
"_index" : { "enabled" : true }

When I run the following query, nothing is returned. Is the index name not stored in the document?

(Christoph) #2

The index name should be stored with the documents, however according to this open issue it is not usable in terms queries (amongst other) yet. As a workaround you could try the Indices Query with only one index.

(Patrick) #3

Thank you Christoph. When I tried the query against my alias, it says that the alias "has more than one indices associated with it" and it "can't execute a single index op"?

"indices" : {
"indices" : ["tweets"]

(Christoph) #4

Sounds like you're trying to index into an alias, that doesn't work. If you have an alias test_indices for three indices i1, i2 and i3 then the following query only returns docs from one index:

GET /test_indices/_search
  "query": {
    "indices": {
      "indices" : ["i1"],
      "query": {
        "match_all": {}
      "no_match_query" : "none"
"hits": {
      "total": 1,
      "max_score": 1,
      "hits": [
            "_index": "i1",
            "_type": "test",
            "_id": "1",
            "_score": 1,
            "_source": {
               "title": "index1"

(Patrick) #5

That was the issue. Thank you so much!

(system) #6