How to determine which terms where matched in a query using the fuzziness parameter

Hello!

So I'm working on a search engine for a customer and I'm using the fuzziness parameter in my query.

The query is as follows:

{
    "from": 0,
    "size": 12,
    "query": {
        "bool": {
            "should": [
                {
                    "bool": {
                        "should": {
                            "match": {
                                "reference": 0
                            }
                        },
                        "boost": 2
                    }
                },
                {
                    "match": {
                        "name": {
                            "query": "pain au chcolat",
                            "cutoff_frequency": 0.01,
                            "minimum_should_match": "3<75%",
                            "analyzer": "french",
                            "fuzziness": "AUTO"
                        }
                    }
                }
            ]
        }
    }
}

As you can see it the search engine is for a french website. In the graphic concept they want to highlight matched results.

In the example I gave you the query will match pain chocolat. I'd like to be able to highlight both 'pain' and 'chocolat' but I don't know if Elasticsearch can tell me which terms were matched.

Could you guys please give me a hint?

Thanks a lot!

Did you try with chocolatine? :rofl:

Did you try https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html?

1 Like

:rofl:

Thanks it worked perfectly! I was looking in the fuzzy query section of the documentation.

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