Inner hits and script score

(nicolas) #1

i have a mapping structured a la "post with comments" = with nested object

let that that for each comment i have the number of like as property

post1 with comments : [{text:asd. likes:3), {text;asdadsa likes:3]
post2 with comments : [{text:fdg. likes:4), {text;asdagf likes:1]
post3 with comments : [{text:rwe. likes:1), {text;asda likes:1]

I would like to retrieve the N posts with comments being the most liked.

the resutls should be
post 2
post 1
post 3

any guide to help me?

  1. I would like to use as document score the number of like of the most liked comments of the post . How to do that?
    with ES and function score / script score? how to first access the fields of inner hits via a scripted score?

thanks a lot !

(system) #2