As it's described in Solr space http://blog-archive.griddynamics.com/2015/08/scoring-join-party-in-solr-53.html you can add a function query for price value field in a child query as SHOULD, then pass ScoreMode into BlockJoinQuery and it will yield scores. There are two things to mention: I'm not sure about function query in Lucene particularly, but there should be an analog, and also there is https://lucene.apache.org/core/6_2_0/join/org/apache/lucene/search/join/ToParentBlockJoinSortField.html Hope it helps.
On Mon, Nov 28, 2016 at 2:46 PM, ASKozitsin <askozit...@gmail.com> wrote: > Here is an example: > > I've got 3 Offerings with such prices: > [Offering1 : { id : 1, price : { value: [10, 30, 20], type : t1 } }, > Offering2 : { id : 2, price : { value: [20], type : t2 } }, > Offering3 : { id : 3, price : { value: [15, 40], type : t3} }] > > Originally, I would like to filter data by arbitrary fieldset + sort by > specified fields + support pagination. I would like to get described it all > out of the box. > > As a solution, I've suggested such transformation to fit BlockJoin queries: > > - {id : 1, price.value : 10, price.type : t1, isParent: 0} > - {id : 1, price.value : 30, price.type : t1, isParent: 0} > - {id : 1, price.value : 20, price.type : t1, isParent: 0} > - {id : 1, isParent: 1} > - {id : 2, price.value : 20, price.type : t2, isParent: 0} > - {id : 2, isParent: 1} > - {id : 3, price.value : 15, price.type : t3, isParent: 0} > - {id : 3, price.value : 40, price.type : t3, isParent: 0} > - {id : 3, isParent: 1} > > This solution works for everything, but if i want to make "global sorting", > I will face a problem: > Expected behaviour is that if I sort by price.value, I will retreive: > > for ascending: {id : 1}, {id : 3}, {id : 2} // find "local minima"(LMin) > from children, sort by LMin parents, get id. > for descending: {id : 3}, {id : 1}, {id : 2} // find "local maxima"(LMax) > from children, sort by LMax parents, get id. > > The same thing for combining sorting with filtering. > Seems, that block join does not support this. > > As another solution I can suggest duplicating fields in parent for sorting > and continue filtering by childs, but I would like to avoid doing this. > > I would really appreciate, if you suggest "out-of-the-box" solution or help > me to change the whole approach, in case if it is incorrect. > > > > -- > View this message in context: http://lucene.472066.n3. > nabble.com/BlockJoinQuery-with-sorting-tp4307405p4307650.html > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > > -- Sincerely yours Mikhail Khludnev