elastic / elastic/elasticsearch
fuzziness not working in conjunction with bool_query during multi_match
- Dominant language
- Java
- Stars
- 77.9k
- Forks
- 26.1k
- PR merge metrics
- PR metrics pending
Description
**Elasticsearch version**: 7.6.2
**Describe the feature**:
When I search in the fields created as part of the `search_as_you_type` dataType, I would like some fuzziness leniency, however I am not seeing this. See **steps to reproduce** below for full examples.
**TL;DR**:
1. I would like `beraking` to match documents with `breaking`, via the standard field, with a fuzziness of 1 and a `bool_prefix` query type.
2. I would also like documents with `berak` to match `breaking`, via the `_index_prefix` field, with a fuzziness of 1 and a `bool_prefix` query type.
**Steps to reproduce**:
```
PUT index
{
"mappings": {
"properties": {
"field": {
"type": "search_as_you_type"
}
}
}
}
PUT index/_doc/1
{
"field": "breaking"
}
GET index/_search
{
"query": {
"multi_match": {
"query": "beraking",
"type": "bool_prefix",
"fuzziness": 1,
"fields": [
"field",
"field._2gram",
"field._3gram",
"field._index_prefix"
]
}
}
}
GET index/_search
{
"query": {
"multi_match": {
"query": "berak",
"type": "bool_prefix",
"fuzziness": 1,
"fields": [
"field",
"field._2gram",
"field._3gram",
"field._index_prefix"
]
}
}
}
```
**Additional Notes**:
With query 1, it starts working when "type": "bool_query" is removed but then the `bool_query` nature is no longer preserved. i.e.
```
GET index/_search
{
"query": {
"multi_match": {
"query": "beraking",
"fuzziness": 1,
"fields": [
"field",
"field._2gram",
"field._3gram",
"field._index_prefix"
]
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.