_index field filter performance VS index name in url

From performance perspective, does filtering on _index field behave as if i've set the index name in the URL?

    GET log-*/_doc/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "event_name.keyword": {
              "value": "send_email",
              "boost": 1
            }
          }
        },
                {
          "term": {
            "_index": {
              "value": "log-2021-01",
              "boost": 1
            }
          }
        }
      ],
      "boost": 1
    }
  }, "size":10000
}

VS

    GET log-2021-01/_doc/_search
    {
      "query": {
        "bool": {
          "must": [
            {
              "term": {
                "event_name.keyword": {
                  "value": "send_email",
                  "boost": 1
                }
              }
            }
          ],
          "boost": 1
        }
      }
    }

Anybody? :slight_smile:

I'd prefer the later as elasticsearch will have only one index to visit IMHO.

Thanks @dadoonet ! so specifying the term query, like

 "term": {
            "_index": {
              "value": "log-2021-01",
              "boost": 1
            }
          }

does not guarantee that only the specified index will be visited right?
For instance, are such things of how elastic engine work internally documented somewhere? i tried to find the answer before asking, no luck...

I think you won't notice a big difference, specifically the second time you run the search as elasticsearch will know that it's useless to visit the index.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.