0
Weight 100 Weight 10
listen>10k listen>10k
publish date>01/01/21 publish date>01/01/20

I tried adding weights separately for publish date but face a challenge when there is same amount of listens. Any help will be appreciated.

Below the query I have tried so far:

{
   "query" : {
     "boosting" : {
       "positive" : {
         "function_score" : {
           "query" : {
             "dis_max" : {
               "queries" : [
                   { "match" : 
                     { "category.name" :
                       {
                         "query" : "TV & Film",
                         "boost" : 1
                       }
                     }
                   }
                 
                  ]
                }
              },
              "functions" : [{"filter": { 
         "range" : { "publishTime": { "gte" : "now-7d", "lte" : "now" } }} ,
         "weight": 1000
     },
     {"filter": { 
        "range" : { "publishTime": { "gte" : "now-15d", "lt" : "now-7d" } }} ,
        "weight": 100
      },
     {"filter": { 
        "range" : { "publishTime": { "gte" : "now-30d", "lt" : "now-15d" } }} ,
        "weight": 10
      },
     {"filter": { 
        "range" : { "publishTime": {"lt" : "now-30d" } }} ,
        "weight": 1
      },
     {"filter": { 
        "range" : { "listen": { "lt" : "10000", "gte" : "1000" } }} ,
        "weight": 1000
      },{"filter": { 
        "range" : { "listen": { "lt" : "100000", "gte" : "10000"} }} ,
        "weight": 100
      },{"filter": { 
        "range" : { "listen": { "lt" : "1000000", "gte" : "100000" } }} ,
        "weight": 10
      },{"filter": { 
        "range" : { "listen": { "lt" : "10000000", "gte" : "1000000" } }} ,
        "weight": 1
      }
               
              ]
            }
          },
          "negative" : {
            "match" : { "studio" : "false" }
           },
           "negative_boost" : 0.1
       }
    }
 }

Expected search link has been attached. Also, can you please help to vary the score from each other [1]: https://i.stack.imgur.com/UkW5N.png

Thanks

  • can you please explain your use case more clearly ? – ESCoder May 28 '21 at 10:42
  • @ESCoder I want to order the best performing episodes in terms of how many times an episode was heard (listen) and recency of episode published(publish date). If I give different weights to the publish date, it works fine. But there can be instances when a recent episode will have lesser listens and performing well than an old episode released 1 year ago which has more listens with time. I would want the recent published episode to rank higher. How can I achieve that? – Chetan Suvarna May 28 '21 at 14:00
  • can you please add some sample index data and expected search result ? – ESCoder Jun 01 '21 at 01:56
  • Hey @ESCoder, have added the details, hope this helps. Please let me know if this makes sense. – Chetan Suvarna Jun 01 '21 at 08:56
  • Still trying to find a solution for this.. Any leads will be appreciated. Thanks – Chetan Suvarna Jun 07 '21 at 09:11

0 Answers0