0

I need to get a document but I have no idea what index it is in. I have a bunch of indices for different days; all prefixed with "mydocs-". I've tried:

GET /mydocs-*/adoc/my_second_doc

returns "index_not_found_exception"


GET /mydocs-*/adoc/_search
{
"query": {
  "bool":{
    "filter": [{
      "term":{
      "_id": ["my_second_doc"] 
    }
    }]
  }
  }
}

returns all the docs in the index.

Now, if I search the specific index I can get the doc. Problem is that I don't always know the index it is in beforehand. So, I'd have to search many, many indices for it (thousands of indices).

GET /mydocs-12/adoc/my_second_doc

returns the desired doc.

Any ideas on how to do an efficient Get/Search for the doc?

1 Answers1

0

Have you tried with :

GET mydocs-*/adoc/_search
{
  "query": {
        "term": {
            "_id": "my_second_doc"
        }
   }
}

Or more specifically with :

GET mydocs-*/_search
{
  "query": {
    "bool": {
        "must": [
           {
               "term": {
                  "_id": "my_second_doc"
               }
           },
           {
               "term": {
                  "_type": "adoc"
               }
           }
        ]
    }
  }
}

The above two queries will find all the documents whose index starting with mydocs-, type is adoc and id is my_second_doc.

sunkuet02
  • 2,376
  • 1
  • 26
  • 33