【问题标题】:How to distinguish context fields in suggestion queries in Solr?如何区分 Solr 中建议查询中的上下文字段?
【发布时间】:2020-11-22 20:02:26
【问题描述】:

我尝试在 Solr 中编写自己的使用上下文字段的建议器。现在配置看起来像这样:

solrconfig.xml

<searchComponent name="suggest" class="solr.SuggestComponent">
  <lst name="suggester">
    <str name="name">mySuggester</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">name</str>
    <str name="suggestAnalyzerFieldType">textSuggest</str>
    <str name="contextField">tags</str>
  </lst>
</searchComponent>

托管模式

<field name="tags" type="textSuggest" multiValued="true" indexed="true" stored="true"/>
<copyField source="address" dest="tags"/>
<copyField source="city" dest="tags"/>
<copyField source="state" dest="tags"/>
<copyField source="categories" dest="tags"/>
<copyField source="stars" dest="tags"/>

当我进行查询时,它看起来像

suggest?сfq=Scottsdale&amp;q=carlos.

我想查询

suggest?сfq=city:Scottsdale&amp;q=carlossuggest?сfq=stars:5.0&amp;q=carlos

所以我想区分上下文字段。

我知道我可以使用有效载荷字段,但我不明白如何使用。或者改一个存储上下文字段的结构,但是找不到。

【问题讨论】:

  • 这能回答你的问题吗?

标签: java solr autosuggest search-suggestion


【解决方案1】:

有些建议器不支持有效载荷字段。

您可以在 solr config xml 文件中的建议器定义中添加如下内容

 <str name="payloadField">tags</str>

并重建建议器。然后,您的建议将包含有效负载字段。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-13
    • 2015-09-06
    • 1970-01-01
    • 1970-01-01
    • 2017-07-04
    • 1970-01-01
    相关资源
    最近更新 更多