在Solr搜索中也显示没有孩子的父母



我调用了一个相当复杂的搜索查询,这样结果中只显示父记录(无子记录的根记录(和子记录的父记录(同时搜索父记录和子记录(。我的查询(Solr搜索顶级和嵌套记录(运行得很好,除非父级没有任何子级,否则它不会显示在搜索结果中。我希望你能帮我更改查询,这样没有孩子的父母也会出现在搜索结果中。

我正在使用的带有url参数的查询如下所示:

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

这转化为以下带有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"
}
},

上传的带孩子的记录如下:https://drive.google.com/file/d/1wZoCZDUS7evpA8ssSvSB1WlWmvNgp_wE/view?usp=sharing

并且在不包含子项的情况下重新发布此记录(例如,删除">childDocuments"列表(可防止无子项的父项在任何位置搜索期间显示在结果中。

任何指导都将非常感谢修复上述搜索,以便在搜索结果中显示孩子的父母和没有孩子的父母记录。

谢谢你抽出时间。

问题出现在q参数中。作为一个人,结构一目了然——两个子句的布尔OR,其中一个是"或";"父";查询,右侧为"查询";edismax";。然而,对于Solr来说,如果一个查询字符串以{!开头,那么如果有v本地参数,那么下一个}之后的所有内容都会被忽略。解决方案很简单——只需在那里放一个空格,就像我看到你已经为q.child做过的那样(它实际上不需要这个空格(。我提交了以下文件:https://issues.apache.org/jira/browse/SOLR-15906

最新更新