solr:仅搜索结果在特定字段中具有值的文档

时间:2013-12-04 17:43:13

标签: solr

我在schema.xml中有这些字段:

<field name="type" type="string" indexed="true" stored="true"/>
<field name="id_boutique" type="string" indexed="true" stored="true"/>
<field name="nom" type="text_full" indexed="true" stored="true" omitNorms="false"/>
<field name="nom_boutique" type="string" indexed="false" stored="true"/>
<field name="categorie_nom" type="string" indexed="false" stored="true"/>
<field name="description" type="text_full" indexed="true" stored="true"/>
<field name="detail" type="text_full" indexed="true" stored="true"/>
<field name="url" type="string" indexed="false" stored="true"/>
<field name="logo" type="string" indexed="false" stored="true"/>
<field name="logo_boutique" type="string" indexed="false" stored="true"/>
<field name="textng" type="autocomplete_ngram" indexed="true" stored="true" multiValued="true" termVectors="true" termPositions="true" termOffsets="true" omitNorms="false" />

作为搜索结果,我希望只获得在“徽标”字段中具有值的文档。 请注意,我使用此配置:

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">textng</str>
<str name="defType">edismax</str>
<str name="rows">100</str>
<str name="fl">*,score</str>
<str name="qf">textng logo^5</str>
<str name="sort">type asc, score desc</str>
<str name="pf">textng^100</str>
<double name="typeboost">1.0</double>
<str name="debugQuery">false</str>
</lst>
<arr name="first-components">
<str>spellcheck</str>
</arr>
</requestHandler>

感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

要提取徽标字段具有某些值的结果,您可以在搜索中添加筛选查询。它看起来像:

http://localhost:8080/select/?q=*:*&fq=logo:["" TO *]

或者如果您想在上面的请求处理程序中执行此操作,它将如下所示:

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="df">textng</str>
<str name="defType">edismax</str>
<str name="rows">100</str>
<str name="fl">*,score</str>
<str name="qf">textng logo^5</str>
<str name="fq">logo:["" TO *]</str>
<str name="sort">type asc, score desc</str>
<str name="pf">textng^100</str>
<double name="typeboost">1.0</double>
<str name="debugQuery">false</str>
</lst>
<arr name="first-components">
<str>spellcheck</str>
</arr>
</requestHandler>

注意:我已将<str name="fq">logo:["" TO *]</str>添加到您的请求处理程序。

相关问题