# How could I search an array of terms using wildcard

**URL:** https://discuss.elastic.co/t/how-could-i-search-an-array-of-terms-using-wildcard/158397
**Category:** Elasticsearch
**Created:** [November 27, 2018, 6:17pm UTC](https://discuss.elastic.co/t/how-could-i-search-an-array-of-terms-using-wildcard/158397 "2018-11-27T18:17:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gabriel\_Pellegrini\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriel_pellegrini_m/32/26713_2.png) [@Gabriel\_Pellegrini\_M](https://discuss.elastic.co/u/Gabriel_Pellegrini_M)
#### Post date: [November 27, 2018, 6:17pm UTC](https://discuss.elastic.co/t/how-could-i-search-an-array-of-terms-using-wildcard/158397/1 "2018-11-27T18:17:19Z")

</div>

I'm looking for a way to search an array of items where should have wildcards in their extremities.  
I tried to use query\_string, but this search does not allow an array search.

```
    {"query": {
            "bool": {
              "must": [
                {
                  "query_string": {
                    "query": ["*item1*","*item2*"],
                    "fields": [
                      "fiscalID"
                    ],
                    "default_operator": "OR"
                  }
                }
              ]
          }
      }
    }

```

If someone has any solution I will really appreciate it.  
Thanks.

---

<div class="post-metadata">

### Author: ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)
#### Post date: [November 28, 2018, 7:05am UTC](https://discuss.elastic.co/t/how-could-i-search-an-array-of-terms-using-wildcard/158397/2 "2018-11-28T07:05:53Z")

</div>

You do not need to provide an array of search terms. If you provide the terms in a single string, the query\_string query will break it up wherever it finds an operator (in this case the wildcards). Try this:

```auto
GET my_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "*item1* *item2*",
            "fields": [
              "fiscalID"
            ]
          }
        }
      ]
    }
  }
}

```

OR is already the default operator, you can omit that.

---

<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: [December 26, 2018, 7:06am UTC](https://discuss.elastic.co/t/how-could-i-search-an-array-of-terms-using-wildcard/158397/3 "2018-12-26T07:06:03Z")

</div>

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