Specifying field weight during query time

I have an index with below mapping.

{
    "mappings" : {
        "_doc" : {
            "properties" : {
                "author" : {"type" : "keyword"},
                "title" : { "type" : "keyword" },
                "description" : {"type" : "text"},
                "summary" : {"type" : "text"}
            }
        }
    }
}

I am trying to query for documents using the endpoint- http://<host>:<port>/<index_name>/_search with following request body:

{
    "query": {
        "bool": {
            "must": [
                {
                    "query_string": {
                        "query": "(content:magicapp* OR magicapp*)"
                    }
                }
            ]
        }
    }
}

I would like to specify the weights for the fields which are present in my mapping. Hence I am trying to add below to my request body.

"search_fields": {
        "title": {
            "weight": 10
        },
        "description": {
            "weight": 5
        },
        "summary": {
            "weight": 3
        }
    }

I tried specifying above block at different places in my request body but every time I am getting the following error:

Unknown key for a START_OBJECT in [search_fields]

Hence I am not sure how to specify the field weights in the above query. Can anyone help me with this? Thanks in advance.

P.S. I know what weights is and have already gone through this link.

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