How to give different weights to exact, phonetic and fuzzy queries?

Hi,
So currently I am using the following query:

{
    "_source": [
        "title",
        "bench",
        "id_",
        "court",
        "date"
    ],
    "size": 15,
    "from": 0,
    "query": {
        "bool": {
            "must": {
                "multi_match": {
                    "query": "knife",
                    "fields": [
                        "title",
                        "body"
                      
                    ],
                    "operator": "and"
                }
            },
            "should": {
                "multi_match": {
                    "query": "knife",
                    "fields": [
                        "title",
                        "body"
                    ],
                    "fuzziness" : 1,
                    "operator": "and"
                }
            }
        }
    },
    "highlight": {
        "pre_tags": [
            "<tag1>"
        ],
        "post_tags": [
            "</tag1>"
        ],
        "fields": {
            "content": {}
        },
        "fragment_size": 30
    }
}

What I want to achieve is that I want to give different weights to exact, phonetic and fuzy queries in the order exact > fuzzy > phonetic. How do I acheive this?

This is my mapping - (My analyzer is a Metaphone analyzer)

{
    "courts_2": {
        "mappings": {
            "properties": {
                "author": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                },
                "bench": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                },
                "citation": {
                    "type": "text"
                },
                "content": {
                    "type": "text",
                    "fields": {
                        "standard": {
                            "type": "text"
                        }
                    },
                    "analyzer": "my_analyzer"
                },
                "court": {
                    "type": "text"
                },
                "date": {
                    "type": "text"
                },
                "id_": {
                    "type": "text"
                },
                "title": {
                    "type": "text",
                    "fields": {
                        "standard": {
                            "type": "text"
                        }
                    },
                    "analyzer": "my_analyzer"
                },
                "verdict": {
                    "type": "text"
                }
            }
        }
    }
}

I shared a script here which can gives you some ideas.

It will use the analyzer you defined for the title field.

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