# Specifying field weight during query time

**URL:** https://discuss.elastic.co/t/specifying-field-weight-during-query-time/288982
**Category:** Elasticsearch
**Created:** [November 11, 2021, 10:45am UTC](https://discuss.elastic.co/t/specifying-field-weight-during-query-time/288982 "2021-11-11T10:45:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Newbie111985](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/newbie111985/32/17561_2.png) [@Newbie111985](https://discuss.elastic.co/u/Newbie111985)
#### Post date: [November 11, 2021, 10:45am UTC](https://discuss.elastic.co/t/specifying-field-weight-during-query-time/288982/1 "2021-11-11T10:45:48Z")

</div>

I have an index with below mapping.

```auto
{
    "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:

```auto
{
    "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.

```auto
"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](https://www.elastic.co/guide/en/app-search/current/relevance-tuning-guide.html) link.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [December 9, 2021, 10:46am UTC](https://discuss.elastic.co/t/specifying-field-weight-during-query-time/288982/2 "2021-12-09T10:46:42Z")

</div>

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