Hello Mikhail,
thank you for your answer. Though we were not able to get it working, we understood the strategy you followed and this helped us to understand Solr more. In fact we could write a query that doesn't do exactly what we asked, but it's very similar and takes into account child documents to boost the results dynamically. As it could be interesting to other developers I paste it here: q=+{!edismax qf='title^5 description' v='great'} {!parent which='_parent_:true' score=max v=$q1} &q1={!boost b=rating score=max v=$q2} &q2=country:AU Thank you again for your assistance! Ned ________________________________ Von: Mikhail Khludnev <m...@apache.org> Gesendet: Sonntag, 9. Juli 2023 11:29 An: users@solr.apache.org <users@solr.apache.org> Betreff: Re: boosting score by child document and returning only parents q=+{!edismax qf='title^5 summary' v=$pq} {!parent which='parent:true' score=max v=$favorsAU}&pq=great&favorsAU=#_parent_:false {!func}product(field(rating),query($AU,1))&AU=country:AU^=2 > > On Tue, Jul 4, 2023 at 9:43 PM Mikhail Khludnev <m...@apache.org> wrote: > >> Hello Ned. >> Make sure you check the guide first >> https://deu01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsolr.apache.org%2Fguide%2Fsolr%2Flatest%2Fquery-guide%2Fsearching-nested-documents.html%23parent-query-parser&data=05%7C01%7Cnedyalko.zhekov%40freelance.de%7Cc01cda2a0d2a4f663e4808db805f0fd2%7C5846b1298c984422b5285c15a8f724b7%7C0%7C0%7C638244917995286164%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2FKiiPy6c7tRfJfldr5HdVSVNtTINpA1f81WY0aymhdo%3D&reserved=0<https://solr.apache.org/guide/solr/latest/query-guide/searching-nested-documents.html#parent-query-parser> >> Note that Solr syntax is cumbersome. >> Basically you need to combine two queries parent and joined parents. >> q=+{!edismax qf='title^5 summary' v=$pq} {!parent which='parent:true' >> score=max v='+docType:author country:Au^=10'}&pq=great >> After every attempt check debugQuery=true output to make sure the query >> is pared as expected. >> It make sense to start with JSON Query DSL. >> Good luck. >> >> On Tue, Jul 4, 2023 at 5:44 PM nedyalko.zhe...@freelance.de.INVALID >> <nedyalko.zhe...@freelance.de.invalid> wrote: >> >>> >>> Hello everyone, >>> >>> we are using Solr for about 2 years and now we want to extend our >>> queries to improve the relevance. In our case we have parent and child >>> documents and in some cases child documents could help us to improve the >>> way we are sorting the results. The problem is we didn't find at the moment >>> an easy way to boost parent documents based on their child documents and we >>> think we are doing something wrong, as this is a common use case. This >>> could be an example of parent and child document: >>> >>> - Parent document >>> { >>> "_parent_": true, >>> "_root_": "book/1" >>> "id": "book/1", >>> "docType": "book", >>> "title": "Great expectations" >>> "summary": "... some text ..." >>> } >>> >>> - Child document >>> { >>> "_parent_": false, >>> "_root_": "book/1" >>> "id": "author/1", >>> "docType": "author", >>> "name": "Charles Dickens" >>> "country": "England" >>> "rating": 4.6 >>> } >>> >>> This could be a query: >>> q=great >>> &defType=edismax >>> &qf=title^5 summary >>> &fq=docType:book >>> &fl=*,score >>> >>> Now, how to extend this query if we want to add the rating field from >>> author document to the related book document score? Furthermore, what if we >>> want to boost books written by Australian authors adding two times their >>> rating value? In both cases, how to get only parent documents in the result? >>> >>> Thank you in advance. >>> Ned >>> >> >> >> -- >> Sincerely yours >> Mikhail Khludnev >> > > > -- > Sincerely yours > Mikhail Khludnev > -- Sincerely yours Mikhail Khludnev