Searching for multiple values in array using wildcards

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

Please format your code using </> icon as explained in this guide 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):

1 Like

Thanks. Will try that approach.

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