# Performance of filtered wildcard queries

**URL:** <https://discuss.elastic.co/t/performance-of-filtered-wildcard-queries/133841>\
**Category:** Elasticsearch\
**Created:** [May 30, 2018, 9:37am UTC](https://discuss.elastic.co/t/performance-of-filtered-wildcard-queries/133841 "2018-05-30T09:37:57Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![tobstarr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tobstarr/32/31727_2.png) [@tobstarr](https://discuss.elastic.co/u/tobstarr)\
**Post date:** [May 30, 2018, 9:37am UTC](https://discuss.elastic.co/t/performance-of-filtered-wildcard-queries/133841/1 "2018-05-30T09:37:57Z")

</div>

Hi all,

I have a very simple index structure only containing the fields (project\_id:int and name:string). What I want to do is a wildcard (infix) query on the name field and that scoped with the project\_id. What I am using for this is this search:

```auto
{
  "query": {
    "bool": {
      "must": [
        { "wildcard": { "name": "*test*" } }
      ],
      "filter": [
        {
          "term": { "project_id": 4711 }
        }
      ]
    }
  }
}

```

The problem is, no matter how many documents are selected by the project\_id filter, the initial queries for the wildcard always take ~ 200ms (having 17mio records in the index). That even happens when the filter does not select any documents at all (like when using -1 for the project ID).

Is there anything I can do to make those initial queries to perform better?

---

_[View the full topic](https://discuss.elastic.co/t/performance-of-filtered-wildcard-queries/133841)._
