Thank you very much for your answer, Mikhail! It has helped a lot!

We have tested it and have played around combining other queries. However we 
weren't able to boost dynamically the results. This was the second part of our 
question: "what if we want to boost books written by Australian authors adding 
two times their rating value?". With a constant value it works, it works very 
well, this is what your example query does. We have tried to use the rating 
field instead of a constant, but without success. Is it very complex to add 
this dynamic boost to the previous query? Maybe the approach must be different?



Thank you in advance.


Ned

________________________________
Von: Mikhail Khludnev <m...@apache.org>
Gesendet: Dienstag, 4. Juli 2023 20:43
An: users@solr.apache.org <users@solr.apache.org>
Betreff: Re: boosting score by child document and returning only parents

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%7Cdcb96d04a7cc4a5e5b2f08db7cbea700%7C5846b1298c984422b5285c15a8f724b7%7C0%7C0%7C638240930509502169%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PKkW0dG3pEx%2FXdnShtuQPV52G3hr0VQ7VK3ots%2BN9Z8%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

Reply via email to