opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.79k stars 1.82k forks source link

Fuzziness support for `bool_prefix`-type `multi_match` queries #6777

Open haversnail opened 1 year ago

haversnail commented 1 year ago

Is your feature request related to a problem? Please describe. Yes, see this open issue from Elasticsearch. TL;DR, querying search_as_you_type fields with the recommended multi_match bool_prefix query does not take into account any "fuzziness" value.

Steps to reproduce:

PUT /my_index

{
  "mappings": {
    "properties": {
      "field": {
        "my_field": "search_as_you_type"
      }
    }
  }
}

PUT /my_index/_doc/1

{
  "my_field": "license"
}

GET /my_index/_search

{
  "query": {
    "multi_match": {
      "query": "lisence", // misspelled word
      "type": "bool_prefix",
      "fuzziness": 1,
      "fields": [
        "my_field",
        "my_field._2gram",
        "my_field._3gram"
      ]
    }
  }
}

Currently, the steps above yield the following result:

{
  // ...
  "hits": {
    "total": {
      "value": 0,
      "relation": "eq"
    },
    "max_score": null,
    "hits": []
  }
}

Describe the solution you'd like It would be beneficial and intuitive to have fuzziness applied to the final search term, so that results are still returned as they would be for other common datatypes/query types with a fuzziness property specified.

Describe alternatives you've considered

epiphanatic commented 6 months ago

This issue has been known about for about 3 years - Elastic search, I hope you guys realize that this exact issue is your competitors greatest strength

dblock commented 6 months ago

@epiphanatic care to contribute, maybe start by adding (failing) YAML REST tests that express the behavior you're looking for?