我使用Solr建议器组件进行自动完成(当用户开始在搜索字段中输入内容时,会向用户建议一些搜索字词)。我想显示建议的总数,但只能在响应中收到最多5个条款。 我的配置如下所示:
<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
<str name="name">product_name_suggester</str>
<str name="lookupImpl">FuzzyLookupFactory</str>
<str name="dictionaryImpl">DocumentDictionaryFactory</str>
<str name="field">product_name</str>
<str name="suggestAnalyzerFieldType">text_general</str>
<str name="buildOnStartup">false</str>
<str name="buildOnCommit">false</str>
<str name="storeDir">product_name_dict</str>
</lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
<str name="suggest">true</str>
<str name="suggest.count">10</str>
<str name="suggest.dictionary">product_name_suggester</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
我使用的请求如下所示:
https://localhost:8984/solr/products_index/suggest?indent=on&suggest.q=M&wt=json&suggest.count=5&suggest.build=true
在结果中,numFound字段总是与我发送的suggest.count字段相同,除非发现较少(例如,如果在上面的示例中仅发现3个,则将在numFound中返回3)。我想要的是即使我只请求5条建议,在numFound字段中获得建议的总匹配数,而不必使用常规的solr-search(/ select)。谁能告诉我如何做到这一点或我做错了什么?
非常感谢