How to return unmatched record with different score

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.

Check out the bool query and especially the should clause with a minimum should match parameter.

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.

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