# Searching for multiple values in array using wildcards

**URL:** https://discuss.elastic.co/t/searching-for-multiple-values-in-array-using-wildcards/117349
**Category:** Elasticsearch
**Created:** [January 28, 2018, 8:42am UTC](https://discuss.elastic.co/t/searching-for-multiple-values-in-array-using-wildcards/117349 "2018-01-28T08:42:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![arieltk](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@arieltk](https://discuss.elastic.co/u/arieltk)
#### Post date: [January 28, 2018, 8:42am UTC](https://discuss.elastic.co/t/searching-for-multiple-values-in-array-using-wildcards/117349/1 "2018-01-28T08:42:14Z")

</div>

Hi all,  
I have an array with several values. For example, in these two documents I have the following arrays:  
1 - tags: ["Apple TV", "TV"]  
2 - tags: ["Apple", "TV"]

If I want to search for "Apple TV", I can send a query as the following:

```
  "query": {
                    "bool": {
                        "must": [
                            {"query_string": {"query": "Apple t* " , "analyze_wildcard": true}}
                        ]
                    }
                }

```

The problem in this case is that in this case the document #2 will get a higher score.  
If I query with "Apple TV" as a phrase, the scoring will be what I expect, but sending a phrase won't allow me to use wildcards:

```
 "query": {
                    "bool": {
                        "must": [
                            {"query_string": {"query": "\\"Apple t*\\" " , "analyze_wildcard": true}}
                        ]
                    }
                }

```

will not return any values...

So the question is:

How can I use wildcards in phrases so I can search for vales in Array that contains phrases and not just words?

Thanks

---

<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 28, 2018, 10:23am UTC](https://discuss.elastic.co/t/searching-for-multiple-values-in-array-using-wildcards/117349/2 "2018-01-28T10:23:15Z")

</div>

Please format your code using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

Please edit your post.

You should better think about it in a different way IMO. You can combine different kind of search in a `bool` query with `should` clauses and never use wildcards.

I shared an example (not with partial terms though but that should may be help):

> <https://gist.github.com/dadoonet/5179ee72ecbf08f12f53d4bda1b76bab>

---

<div class="post-metadata">

### Author: ![arieltk](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@arieltk](https://discuss.elastic.co/u/arieltk)
#### Post date: [January 28, 2018, 2:55pm UTC](https://discuss.elastic.co/t/searching-for-multiple-values-in-array-using-wildcards/117349/3 "2018-01-28T14:55:58Z")

</div>

Thanks. Will try that approach.

---

<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: [February 25, 2018, 2:56pm UTC](https://discuss.elastic.co/t/searching-for-multiple-values-in-array-using-wildcards/117349/4 "2018-02-25T14:56:23Z")

</div>

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