# Weighted fields in query string or boost in should clauses

**URL:** <https://discuss.elastic.co/t/weighted-fields-in-query-string-or-boost-in-should-clauses/22428>\
**Category:** Elasticsearch\
**Created:** [February 27, 2015, 10:29am UTC](https://discuss.elastic.co/t/weighted-fields-in-query-string-or-boost-in-should-clauses/22428 "2015-02-27T10:29:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pir\_Abdul\_Rasool](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@Pir\_Abdul\_Rasool](https://discuss.elastic.co/u/Pir_Abdul_Rasool)\
**Post date:** [February 27, 2015, 10:29am UTC](https://discuss.elastic.co/t/weighted-fields-in-query-string-or-boost-in-should-clauses/22428/1 "2015-02-27T10:29:36Z")

</div>

Which way is better to accomplish query\_string field search in multiple  
fields with different weights?

# 1st way:

{  
"query": {  
"query\_string": {  
"query": "cats",  
"fields": [  
"en\_keywords\_1^5",  
"en\_keywords\_2^2",  
"en\_keywords\_3"  
],  
"use\_dis\_max": true  
}  
}  
}

# 2nd way:

{  
"query": {  
"bool": {  
"must": [  
{  
"query\_string": {  
"query": "cats",  
"fields": [  
"en\_keywords\_1",  
"en\_keywords\_2",  
"en\_keywords\_3"  
]  
}  
}  
],  
"should": [  
{  
"query\_string": {  
"query": "cats",  
"fields": [  
"en\_keywords\_1"  
],  
"boost": 5  
}  
},  
{  
"query\_string": {  
"query": "cats",  
"fields": [  
"en\_keywords\_2"  
],  
"boost": 3  
}  
}

```
        ]
    }
}

```

}

and What are pros and cons of both approaches?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/668da3ec-2e2b-4db1-bfc3-d62d8ff2e8f1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/668da3ec-2e2b-4db1-bfc3-d62d8ff2e8f1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:29am UTC](https://discuss.elastic.co/t/weighted-fields-in-query-string-or-boost-in-should-clauses/22428/2 "2017-07-06T00:29:33Z")

</div>


