# Does different query code affect search performance?

**URL:** <https://discuss.elastic.co/t/does-different-query-code-affect-search-performance/113783>\
**Category:** Elasticsearch\
**Created:** [January 2, 2018, 1:33pm UTC](https://discuss.elastic.co/t/does-different-query-code-affect-search-performance/113783 "2018-01-02T13:33:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![f26227279](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f26227279/32/21296_2.png) [@f26227279](https://discuss.elastic.co/u/f26227279)\
**Post date:** [January 2, 2018, 1:33pm UTC](https://discuss.elastic.co/t/does-different-query-code-affect-search-performance/113783/1 "2018-01-02T13:33:34Z")

</div>

As title, if I have different query API, but the result is the same .  
such as:

```
GET _search
{
"query": {
"bool": {
  "must": [
    {
        "term" : { "_index" : "logstash-2018.01.02" }   
    },
    {
        "term":{"IPV4_DST_ADDR":"192.168.0.159"}
    },
    {
      "range" : {
        "LAST_SWITCHED" : {
            "gte" : 1514166147
        }
        }
    }
  ]
}
}
}

```

if I delete the one line

```
   "term" : { "_index" : "logstash-2018.01.02" }   

```

and the result is the same, does add this one line would raise the search performance?  
beacuse I found the search shards is less when I filter the index.

thank you in advance!

---

<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:** [January 2, 2018, 1:55pm UTC](https://discuss.elastic.co/t/does-different-query-code-affect-search-performance/113783/2 "2018-01-02T13:55:02Z")

</div>

Even better to search with

```
logstash-2018.01.02/_search

```

IMO

---

<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:** [January 30, 2018, 1:55pm UTC](https://discuss.elastic.co/t/does-different-query-code-affect-search-performance/113783/3 "2018-01-30T13:55:14Z")

</div>

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