# \_index field filter performance VS index name in url

**URL:** <https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572>\
**Category:** Elasticsearch\
**Created:** [March 8, 2021, 2:53pm UTC](https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572 "2021-03-08T14:53:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abbass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abbass/32/85817_2.png) [@Abbass](https://discuss.elastic.co/u/Abbass)\
**Post date:** [March 8, 2021, 2:53pm UTC](https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572/1 "2021-03-08T14:53:11Z")

</div>

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

```auto
    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

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

```

---

<div class="post-metadata">

**Author:** ![Abbass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abbass/32/85817_2.png) [@Abbass](https://discuss.elastic.co/u/Abbass)\
**Post date:** [March 19, 2021, 11:39am UTC](https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572/2 "2021-03-19T11:39:41Z")

</div>

Anybody? 🙂

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 19, 2021, 11:56am UTC](https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572/3 "2021-03-19T11:56:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Abbass](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abbass/32/85817_2.png) [@Abbass](https://discuss.elastic.co/u/Abbass)\
**Post date:** [March 19, 2021, 3:00pm UTC](https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572/4 "2021-03-19T15:00:00Z")

</div>

Thanks @dadoonet ! so specifying the term query, like

```auto
 "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...

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 19, 2021, 3:33pm UTC](https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572/5 "2021-03-19T15:33:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 16, 2021, 3:34pm UTC](https://discuss.elastic.co/t/index-field-filter-performance-vs-index-name-in-url/266572/6 "2021-04-16T15:34:14Z")

</div>

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