# How to return unmatched record with different score

**URL:** https://discuss.elastic.co/t/how-to-return-unmatched-record-with-different-score/248704
**Category:** Elasticsearch
**Created:** [September 15, 2020, 3:26pm UTC](https://discuss.elastic.co/t/how-to-return-unmatched-record-with-different-score/248704 "2020-09-15T15:26:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ankit\_Pradhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankit_pradhan/32/44412_2.png) [@Ankit\_Pradhan](https://discuss.elastic.co/u/Ankit_Pradhan)
#### Post date: [September 15, 2020, 3:26pm UTC](https://discuss.elastic.co/t/how-to-return-unmatched-record-with-different-score/248704/1 "2020-09-15T15:26:16Z")

</div>

i have 2 document ...

document 1  
{ "field1": "Value1",  
"field2": "Value2",  
"field3": "Value3"  
}

document 2  
{ "field1": "Value1",  
"field2": "Value2"  
}

When I do a search with "field1": "Value1" and "field2": "Value2" and "field3": "Value3"  
i would like to return both document 1 and 2 but document 1 with much high score, while document 2 with lesser score.

How should I do it?

Please note that in real use case there are more that 15 fields in a document and search criteria could also vary a lot. But all times field names and value to be searched are known.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [September 17, 2020, 12:38pm UTC](https://discuss.elastic.co/t/how-to-return-unmatched-record-with-different-score/248704/2 "2020-09-17T12:38:25Z")

</div>

Check out the [bool query](https://www.elastic.co/guide/en/elasticsearch/reference/7.8/query-dsl-bool-query.html) and especially the `should` clause with a minimum should match parameter.

---

<div class="post-metadata">

### Author: ![Ankit\_Pradhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ankit_pradhan/32/44412_2.png) [@Ankit\_Pradhan](https://discuss.elastic.co/u/Ankit_Pradhan)
#### Post date: [September 23, 2020, 8:16am UTC](https://discuss.elastic.co/t/how-to-return-unmatched-record-with-different-score/248704/3 "2020-09-23T08:16:52Z")

</div>

i don't think this will solve the problem ... in should i have to then manual supply minimum should match parameter ...  
basically, depending on the number of fields ... if i give minimum to match as same as number of fields then it will become like a must query ...  
what i need is if there are 3 documents with varying number of fields ... then when i query with say 2 fields ... then those documents should also come in response which do not have the 2 fields supplied in query.

---

<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: [October 21, 2020, 8:17am UTC](https://discuss.elastic.co/t/how-to-return-unmatched-record-with-different-score/248704/4 "2020-10-21T08:17:10Z")

</div>

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