How to provide more score when the "terms" query has multiple match?


#1

Hello, I started to elasticsearch few weeks ago and I encountered some difficulty finding the appropriate query for the results I am looking for.

Currently, by running the query written below, all documents (except for _doc/1) returns the same score. Ideally, the highest score should be given to the _doc/3since the array has more elements which match the query (so the score should be: id3 > id1 > id2 >id4)

Does elasticsearch provides some tool for doing this?
Any help would be appreciated.

Example of my documents
_doc/1
_id: 1
communities: ["A", "B", "C"]`

_doc/2
_id: 2
communities: ["A"]

_doc/3
_id: 3
communities: ["A","B","C","D","E","F"]

_doc/4
_id: 4
communities:

This is my query

"query": {
"bool": {
"should" : {
"terms" : {
"communities" : ["A", "B", "C", "D"]
"boost": 10
}
}
}
}