简体   繁体   中英

Showing parents without children in Solr search too

I'm calling a rather complex search query so that only parents (root records that are childless) and the parents of children appear in the result (searching through both parent and child records). The query I have from ( Solr search top level and nested records ) works great, except if a parent doesn't have any children, it will not show in the search results. I'm hoping you can help me alter the query so that parents without children appear in the search result too.

The query with url params I'm using looks as follows:

http://localhost:8983/solr/b-core/select?&fq=solr_type:parent&childFilter={!edismax%20v=$q.user}&fl=*,[child%20childFilter=$childFilter%20%20limit=1000]&q={!parent%20which=solr_type:parent%20v=$q.child}%20OR%20{!edismax%20v=$q.user}&q.child=%20%2Bsolr_type:child%20%20%2B{!edismax%20v=$q.user}&q.user=suppressed_b:False&rows=10&start=0&sort=&fq=solr_type:parent

Which translates to the following result with params:

status: 0,
QTime: 9,
params: {
childFilter: "{!edismax v=$q.user}",
ps: "0",
indent: "2",
echoParams: "all",
fl: "*,[child childFilter=$childFilter  limit=1000]",
fq: [
"solr_type:parent",
"solr_type:parent"
],
tie: "0.01",
defType: "lucene",
qf: "...
      ",
q.child: " +solr_type:child  +{!edismax v=$q.user}",
wt: "json",
mm: "6<-1 6<90%",
qs: "1",
q.alt: "*:*",
facet.field: [
...
],
start: "0",
sort: "",
rows: "10",
q: "{!parent which=solr_type:parent v=$q.child} OR {!edismax v=$q.user}",
facet.limit: "10",
spellcheck: "true",
pf: "...
      ",
q.user: "suppressed_b:False",
facet.mincount: "1",
facet: "true",
rid: "-2221"
}
},

An uploaded record with children looks as follows: https://drive.google.com/file/d/1wZoCZDUS7evpA8ssSvSB1WlWmvNgp_wE/view?usp=sharing

And republishing this record without the children (eg removing the ' childDocuments ' list) prevents the childless parent from showing in the results during an anywhere search.

Any guidance would be most greatly appreciated in fixing the above search so that the parent of children and childless parent records appear in the search result.

Thanks for your time.

The problem is in your q param. At a glance as a human, the structure is clear -- a boolean OR of two clauses, one of which is a "parent" query, and the right is "edismax". However to Solr, if a query string starts with {! then everything after the next } is ignored if there is a v local-param, which there is. The solution is simple -- just put a space there, like I see you already did for q.child (which didn't actually need that space). I filed this: https://issues.apache.org/jira/browse/SOLR-15906

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM