Hi All,
I'm trying to model a social network and query it with the search results order with 1st degree connections first 2nd degree connects next and then all other results.
"mappings": {
"entity": {
"properties": {
"id": {
"type": "long"
},
"name": {
"type": "string"
},
"connections": {
"type": "long"
}
}
}
}
For a searching user with connections with ids 3,4,5 I would query it like this:
GET /_search
{
"query": {
"function_score": {
"query": { "match": { "name": "bill" } },
"functions": [
{
"filter": { "terms": { "id": [3, 4, 5] } },
"weight": 1000
},
{
"filter": { "terms": { "connections": : [3, 4, 5] } },
"weight": 10
}
],
"score_mode": "sum"
}
}
}
This works. However, I'd like documents that contain all three connections 3,4 & 5 to rank higher than those that contain only two and those higher than containing only one.
What would be the simplest approach to achieve that ranking?