# Best option for Wildcard Search with multimatch

**URL:** <https://discuss.elastic.co/t/best-option-for-wildcard-search-with-multimatch/261192>\
**Category:** Elasticsearch\
**Created:** [January 14, 2021, 11:34pm UTC](https://discuss.elastic.co/t/best-option-for-wildcard-search-with-multimatch/261192 "2021-01-14T23:34:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajends1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajends1/32/81884_2.png) [@rajends1](https://discuss.elastic.co/u/rajends1)\
**Post date:** [January 14, 2021, 11:34pm UTC](https://discuss.elastic.co/t/best-option-for-wildcard-search-with-multimatch/261192/1 "2021-01-14T23:34:22Z")

</div>

which is the Best option for Wildcard Search with multimatch and why ?

Wildcard with multi-match

```
{

"query": {

"multi_match": {

"query": "*king*",

"fields": [

"text",

"title"

]

}

}

}

```

Alternatively to multi\_match we could use a query\_string query with wildcards.

```
"query": {

"query_string": {

"query": "*king*",

"fields": ["text", "title"]

}

}

```

` `

`Other Options are :`

`multimatch` query requires `match` queries as its internal queries. and a `match` query doesn't support wildcards. Depending how we want to combine scores from multiple fields, we may use [dis\_max query 112](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html), that can accept wildcard queries as well.

` In Elasticsearch, we generally use multi_match query that uses best_fields as its default type`

`multimatch` query requires `match` queries as its internal queries. and a `match` query doesn't support wildcards. Depending how we want to combine scores from multiple fields, we may use [dis\_max query 112](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html), that can accept wildcard queries as well.

The `best_fields` type generates a [`match` query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html) for each field and wraps them in a [`dis_max`](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html) query, to find the single best matching field. For instance, this query:

```
GET /_search

{

"query": {

"multi_match" : {

"query": "king",

"type": "best_fields",

"fields": ["text", "title"],

"tie_breaker": 0.3

}

}

}

```

Copy as cURL[View in Console]([http://localhost:5601/app/kibana#/dev\_tools/console?load\_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/774.console](http://localhost:5601/app/kibana#/dev_tools/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/774.console)

would be executed as:

```
GET /_search

{

"query": {

"dis_max": {

"queries": [

{ "match": { "subject": " king" }},

{ "match": { "message": " king" }}

],

"tie_breaker": 0.3

}

}

}

```

Copy as cURL[View in Console]([http://localhost:5601/app/kibana#/dev\_tools/console?load\_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/775.console](http://localhost:5601/app/kibana#/dev_tools/console?load_from=https://www.elastic.co/guide/en/elasticsearch/reference/current/snippets/775.console)

`fields and per-field boosting`

Fields can be specified with wildcards, eg:

```
"query": {

"multi_match" : {

"query": "king",

"fields": ["title", "*_name"]

}

}

```

`different field mask `

```
{

"query": {

"filtered": {

"query": {

"match_all": {}

},

"filter": {

"bool": {

"should": [

{"query": {"wildcard": {"text": {"value": "*king*"}}}},

{"query": {"wildcard": {"title": {"value": "*king*"}}}}

]

}

}

}

}

}`Preformatted text`
```

---

<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 11, 2021, 11:34pm UTC](https://discuss.elastic.co/t/best-option-for-wildcard-search-with-multimatch/261192/2 "2021-02-11T23:34:25Z")

</div>

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