Elasticsearch search based on term position and fuzzy

I am a beginner in Elasticsearch and I try to combine a query with term position and fuzzy and the results are not what I expected.

I tried this query

{
    "query": {
        "bool": {
            "must": [
                {
                    "bool": {
                        "must": [
                            {
                                "query_string": {
                                    "query": "douille~ raccordment~",
                                    "fields": [
                                        "name^10"
                                    ],
                                    "default_operator": "AND",
                                    "fuzziness": "AUTO:10,20"
                                }
                            }
                        ],
                        "should": [
                            {
                                "span_first": {
                                    "match": {
                                        "span_multi": {
                                            "match": {
                                                "fuzzy": {
                                                    "name": {
                                                        "value": "douille",
                                                        "fuzziness": "AUTO"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "end": 1
                                }
                            },
                            {
                                "span_first": {
                                    "match": {
                                        "span_multi": {
                                            "match": {
                                                "fuzzy": {
                                                    "name": {
                                                        "value": "douille",
                                                        "fuzziness": "AUTO"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "end": 2
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

The word "raccordment" isn't spelled well (in French). The right word is "raccordement". I have a product "Douille Raccordement" in my index and products with "Douille" without "Raccordement" in the name but not in the first position in my index. When I try the query, I have no result.

My aim is to have this kind of results with the search "douille raccordment" (based on term position, with or without misspell):

  • Douille Raccordement
  • Douille 1
  • 10 Douilles
  • Raccordement 1
  • Raccordement 2

I use Elasticsearch 7.

Do you know why?

Thanks for your help

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