Hello Mikhail, thank you very much! Your suggestion fixed the problem.
Have a nice day, Josef Od: "Mikhail Khludnev" <m...@apache.org> Komu: "users" <users@solr.apache.org> Odeslané: Středa, 12. Březen 2025 19:58:23 Předmět: Re: AND-ing several JOINs It's hard to get to the core problem. Here's just a blind guess: souldn't theses filters intersected before join avoiding cross-match? ie fq={!join fromIndex='authority' from='authority_str' to='authority_search_str_mv'}+occupation_facet:"básníci" +gender_facet:"žena"+full_text_str_mv:"Matrika narozených" +full_text_str_mv:"Matrika zemřelých" On Wed, Mar 12, 2025 at 12:46 PM Josef Svoboda <josef.svob...@ucl.cas.cz.invalid> wrote: > Hi all, > > I am using solr 9.3 (with VuFind). I want to use JOIN query to get a list > of books written by certain authors (selected by facets). > First, I do two preparatory steps to try this without JOIN and have some > data to test. > > Step 1: Query authority DB (combining 4 facets) to get list of authors. > > Query: > /solr/authority/select?fl=authority_str&fq=full_text_str_mv%3A"Matrika > narozených"&fq=full_text_str_mv%3A"Matrika > zemřelých"&fq=gender_facet%3A"žena"&fq=occupation_facet%3A"básníci"&indent=true&q.op=OR&q=*%3A*&useParams=&wt=json > > > > For convenience, I copy the contents of fq boxes: > occupation_facet:"básníci" > gender_facet:"žena" > full_text_str_mv:"Matrika narozených" > full_text_str_mv:"Matrika zemřelých" > > Response: > "responseHeader":{ > "status":0, > "QTime":0, > "params":{ > "q":"*:*", > "indent":"true", > "fl":"authority_str", > "q.op":"OR", > "fq":["occupation_facet:\"básníci\"","gender_facet:\"žena\"","full_text_str_mv:\"Matrika > > narozených\"","full_text_str_mv:\"Matrika zemřelých\""], > "wt":"json", > "useParams":"", > "_":"1741770044834" > } > }, > "response":{ > "numFound":6, > "start":0, > "numFoundExact":true, > "docs":[{ > "authority_str":"jk01021170" > },{ > "authority_str":"jk01110447" > },{ > "authority_str":"jk01021755" > },{ > "authority_str":"jk01080703" > },{ > "authority_str":"jk01100238" > },{ > "authority_str":"jk01152591" > }] > } > } > > Step 2: Query biblio DB (using list of authors we got in step 1) to get > list of books. > Query: > /solr/biblio/select?indent=true&q.op=OR&q=authority_search_str_mv%3A(jk01021170 > > jk01021755 jk01080703 jk01100238 jk01110447 jk01152591)&useParams= > > Response: > { > "responseHeader":{ > "status":0, > "QTime":1, > "params":{ > "q":"authority_search_str_mv:(jk01021170 jk01021755 jk01080703 jk01100238 > jk01110447 jk01152591)", > "indent":"true", > "fl":"fullrecord", > "q.op":"OR", > "rows":"10000", > "useParams":"", > "_":"1741770215216" > } > }, > "response":{ > "numFound":1498, > "start":0, > "numFoundExact":true, > "docs":[...] > } > By grepping result for > "jk01021170|jk01021755|jk01080703|jk01100238|jk01110447|jk01152591", I > checked that data contain the results I wanted. > > Step 3: Use join query to combine steps 1 + 2. > Query: > solr/biblio/select?fq={!join fromIndex%3D'authority' > from%3D'authority_str' to%3D'authority_search_str_mv' > v%3D'full_text_str_mv%3A"Matrika narozených"'}&fq={!join > fromIndex%3D'authority' from%3D'authority_str' > to%3D'authority_search_str_mv' v%3D'full_text_str_mv%3A"Matrika > zemřelých"'}&fq={!join fromIndex%3D'authority' from%3D'authority_str' > to%3D'authority_search_str_mv' v%3D'gender_facet%3A"žena"'}&fq={!join > fromIndex%3D'authority' from%3D'authority_str' > to%3D'authority_search_str_mv' > v%3D'occupation_facet%3A"básníci"'}&indent=true&q.op=OR&q=*%3A*&useParams= > > For convenience, I copy the contents of fq boxes: > {!join fromIndex='authority' from='authority_str' > to='authority_search_str_mv' v='occupation_facet:"básníci"'} > {!join fromIndex='authority' from='authority_str' > to='authority_search_str_mv' v='gender_facet:"žena"'} > {!join fromIndex='authority' from='authority_str' > to='authority_search_str_mv' v='full_text_str_mv:"Matrika narozených"'} > {!join fromIndex='authority' from='authority_str' > to='authority_search_str_mv' v='full_text_str_mv:"Matrika zemřelých"'} > > Response: > { > "responseHeader":{ > "status":0, > "QTime":0, > "params":{ > "q":"*:*", > "indent":"true", > "q.op":"OR", > "fq":["{!join fromIndex='authority' from='authority_str' > to='authority_search_str_mv' v='occupation_facet:\"básníci\"'}","{!join > fromIndex='authority' from='authority_str' to='authority_search_str_mv' > v='gender_facet:\"žena\"'}","{!join fromIndex='authority' > from='authority_str' to='authority_search_str_mv' > v='full_text_str_mv:\"Matrika narozených\"'}","{!join fromIndex='authority' > from='authority_str' to='authority_search_str_mv' > v='full_text_str_mv:\"Matrika zemřelých\"'}"], > "rows":"0", > "useParams":"", > "_":"1741770215216" > } > }, > "response":{ > "numFound":1563, > "start":0, > "numFoundExact":true, > "docs":[...] > } > } > > By grepping result for > "jk01021170|jk01021755|jk01080703|jk01100238|jk01110447|jk01152591", I > checked that data contain the 1498 results I wanted, but it also contains > 65 unwanted results. > > (What is perhaps interesting that only 2 of the wanted results are among > the first 10 results.) > > What should I do get rid of these unwanted results? > > Thanks for any help, > Josef > > -- Sincerely yours Mikhail Khludnev