本文介绍了了解 Solr 嵌套查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试理解 solr 嵌套查询,但我在解析语法时遇到了问题.

I'm trying to understand solr nested queries but I'm having a problem undestading the syntax.

我有以下两个索引文档(以及其他):

I have the following two indexed documents (among others):

<doc>
    <str name="city">Guarulhos</str>
    <str name="name">Fulano Silva</str>
</doc>

<doc>
    <str name="city">Fortaleza</str>
    <str name="name">Fulano Cardoso Silva</str>
</doc>

如果我查询 q="Fulano Silva"~2&defType=edismax&qf=name&fl=score 我有:

<doc>
    <float name="score">28.038431</float>
    <str name="city">Guarulhos</str>
    <str name="name">Fulano Silva</str>
</doc>

<doc>
    <float name="score">19.826164</float>
    <str name="city">Fortaleza</str>
    <str name="name">Fulano Cardoso Silva</str>
</doc>

所以我想如果我查询:

q="Fulano Silva"~2 AND __query__="{!edismax qf=city}fortaleza" &defType=edismax&qf=name&fl=score

我会为第二个文档提供更高的分数,但实际上我得到了一个空结果集,numFound=0.

I'd give a bit more score for the second document, but actually I get an empty result set with numFound=0.

我在这里做错了什么?

推荐答案

需要去掉="并用:"代替,才能使用嵌套查询语法:

Need to remove the "=" and replace it with ":" to use the nested query syntax:

q="Fulano Silva"~2 AND _query_:"{!edismax qf=city}fortaleza" &defType=edismax&qf=name&fl=score

q="Fulano Silva"~2 AND _query_:"{!edismax qf=city}fortaleza" &defType=edismax&qf=name&fl=score

*使用 _query_: 而不是 _query_=

希望这有效...

这篇关于了解 Solr 嵌套查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 11:38