Score boosting for terms query

I would like to ask for help with following issue. My goal is to list events of followers and then sort the events by count of followers who are following the event.

Mapping example:

 {
  "event": {
    "mappings": {
      "type": {
        "dynamic": "false",
        "properties": {
          "followers": { "type": "long" },
          ...many more...
        }

where followers are user ids related to specific event. First part of task is pretty simple, I can match events of related users by simple terms query, something like

{
"terms" : {
"followers" : [
1,
27,
97,
..

but the second part is bit tricky. I want to order the result set by number of matched followers. Since I went through lot of issues (here, stack, elastic github), I thought the way will be using function score.

but so far it seems like a wrong way because what would be the best for me is something like:

GET /_search
{
"query": {
"function_score": {
...
"score_mode": "by_terms_matched",
...

because nothing else (from my point of view and testing) doesn't suit the needs. Most of the people recommends doing more terms queries and boost each and single one, but this is unusable for me, since the number of my followers is relative (it will be different for every user).

Is there any terms query related parameter which would boost documents by count of matched terms?

I was also thinking about aggregations but they don't fit such a task, so from my point of view I will have to do some magic via script sorting, but first I would like to try to ask for help here.

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