Disable Fuzziness in Query

I am fetching results with the following query where search is being done on Strings (Recipe name):

let body2 = {
        size: 200,
        from: 0,
        sort : [
            { "@timestamp" : {"order": "desc", "format": "strict_date_optional_time_nanos"}}
        ],
        //fuzziness: "1",// "AUTO: 0,2",
        query: {
            // Recipe: req.query['q'],
            // FLAG: 'END'
            bool: {
                must: [
                    {
                        match: {
                            Line: req.query['q']
                        }
                    },
                    {
                        match: {
                            FLAG: "END"
                        }
                    },
                    {
                        match: {
                            Recipe: req.query['recipe']
                        }
                    },
                    {
                        range: {
                            "@timestamp": {
                                gte: req.query['sDate'],
                                lte: req.query['eDate']
                            }
                        }
                    }
                ]
            }
        }

The response I am getting contains those results as well which are not a complete match with the searched recipe (contains those results which has some matching substring). Is there anyway for me to remove fuzziness and only fetch those results which have a 100% match?

Fuzziness is disabled by default, so if you leave it out, this is not the reason for documents matching. However the match query uses the OR operator by default. Keep that in mind when searching for several terms.

1 Like

Thanks @spinscale Is there a way to change this default OR to AND?

no, this needs to be done as part of the query.

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