# Fuzziness not work with bool\_prefix multi\_match (search-as-you-type)

**URL:** <https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602>\
**Category:** Elasticsearch\
**Created:** [April 24, 2020, 8:51am UTC](https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602 "2020-04-24T08:51:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrewbien](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andrewbien](https://discuss.elastic.co/u/andrewbien)\
**Post date:** [April 24, 2020, 8:51am UTC](https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602/1 "2020-04-24T08:51:28Z")

</div>

Hi everyone.  
I struggling with a problem is that fuzziness not work with multi\_match bool\_prefix query , but I found on document that fuzziness option was supported:

[https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-multi-match-query.html#type-bool-prefix](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-multi-match-query.html#type-bool-prefix)

Here is my query:

```auto
{
  "_source": {},
  "query": {
    "multi_match": {
      "query": "dross",
      "type": "bool_prefix",
      "fields": [
        "title",
        "title._2gram",
        "title._3gram"
      ],
      "fuzziness": "AUTO"
    }
  }
}

```

I'm using Elasticsearch 7.4, and trying to use Search-as-you-type feature in Elasticsearch 7.4: [https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-as-you-type.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.x/search-as-you-type.html)

Here is my example to reproduce issue:

- Create a index with a field has search-as-you-type field type, and indexing a document:

```auto
PUT my_index
{
  "mappings": {
    "properties": {
      "my_field": {
        "type": "search_as_you_type"
      }
    }
  }
}

PUT my_index/_doc/1?refresh
{
  "my_field": "dress"
}

```

- After that I query with multi\_match bool\_prefix, with query term is "dross" (I assume that user when searing made mistake):

```auto
GET my_index/_search
{
  "query": {
    "multi_match": {
      "query": "dross",
      "type": "bool_prefix",
      "fields": [
        "my_field",
        "my_field._2gram",
        "my_field._3gram"
      ],
      "fuzziness": "AUTO"
    }
  }
}

```

The result is empty. But my expectation is that it should show the result is "dress" like this:

```auto
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "my_field" : "dress"
        }
      }
    ]
  }
}

```

Anyone can help? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [April 24, 2020, 9:18am UTC](https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602/2 "2020-04-24T09:18:52Z")

</div>

Can you explain a bit more about whats not working? Do you get errors? Are certain documents you would expect to match not returned? In this case, can you give some examples?

---

<div class="post-metadata">

**Author:** ![andrewbien](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andrewbien](https://discuss.elastic.co/u/andrewbien)\
**Post date:** [April 24, 2020, 9:29am UTC](https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602/3 "2020-04-24T09:29:48Z")

</div>

HI @cbuescher  
Thanks for your quick reply, here is my example:

- Create a index with a field has search-as-you-type field type, and indexing a document:

```auto
PUT my_index
{
  "mappings": {
    "properties": {
      "my_field": {
        "type": "search_as_you_type"
      }
    }
  }
}

PUT my_index/_doc/1?refresh
{
  "my_field": "dress"
}

```

- After that I query with multi\_match bool\_prefix, with query term is "dross" (I assume that user when searing made mistake):

```auto
GET my_index/_search
{
  "query": {
    "multi_match": {
      "query": "dross",
      "type": "bool_prefix",
      "fields": [
        "my_field",
        "my_field._2gram",
        "my_field._3gram"
      ],
      "fuzziness": "AUTO"
    }
  }
}

```

The result is empty. But my expectation is that it should show the result is "dress" like this:

```auto
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "my_field" : "dress"
        }
      }
    ]
  }
}

```

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [April 24, 2020, 10:50am UTC](https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602/4 "2020-04-24T10:50:15Z")

</div>

I think the explanation can be found in [Multi-match query | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-bool-prefix)

> The `fuzziness` , `prefix_length` , `max_expansions` , `rewrite` , and `fuzzy_transpositions` parameters are supported for the terms that are used to construct term queries, but do not have an effect on the prefix query constructed from the final term.

If, for example, you index "dress" and "dress code" and search with `"query": "dross c",` you should find both documents (works at least for me on 7.6.2). I can understand that this is a bit counter-intuitive, but then again users typing should be able to find the correct terms after typing "dr".

---

<div class="post-metadata">

**Author:** ![andrewbien](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andrewbien](https://discuss.elastic.co/u/andrewbien)\
**Post date:** [April 24, 2020, 3:59pm UTC](https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602/5 "2020-04-24T15:59:20Z")

</div>

Oh, I see , thank you @cbuescher 🙂

---

<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:** [May 22, 2020, 3:59pm UTC](https://discuss.elastic.co/t/fuzziness-not-work-with-bool-prefix-multi-match-search-as-you-type/229602/6 "2020-05-22T15:59:26Z")

</div>

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