【问题标题】:Multiple word suggest based on matching documents on the first word多词建议基于匹配文档的第一个词
【发布时间】:2014-02-21 02:41:50
【问题描述】:

我正在使用 Solr 4.6,我正在尝试让 solr 根据多个单词给我自动完成建议。我已经使用 spellcheck.collat​​e 实现了这一点,但我现在面临的问题是它返回的建议与搜索无关(搜索基于汽车)

Example: Searching for something like "audi fo" will return audi + all the matching
items that have "fo" in them, something like audi ford, audi focus and so on.

每个文档都有多个字段(品牌、型号、车身颜色等)。我想要实现的是让 solr 根据第一个词只返回匹配文档中匹配字段的第二个词的建议。

我想我可以使用 Solr 库在 Java 中编写一个自定义组件并将其插入,但我猜测必须有一种更简单的方法来使用 Solr 已经知道的实现这一点。

注意:这几天我一直在研究 Solr 文档,这是迄今为止我能找到的最好的。

solr.config

<searchComponent name="com_test" class="solr.SpellCheckComponent">
 <lst name="spellchecker">
   <str name="name">com_test</str>
   <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
   <str name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookup</str>
   <str name="field">com_test</str>
   <str name="buildOnCommit">true</str>
 </lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/com_test">
  <lst name="defaults">
    <str name="spellcheck">true</str>
    <str name="spellcheck.dictionary">com_test</str>
    <str name="spellcheck.count">10</str>
    <str name="spellcheck.collate">true</str>
  </lst>
  <arr name="components">
    <str>com_test</str>
  </arr>
</requestHandler>

schema.xml

<field name="com_test" type="com_test" indexed="true" stored="false" multiValued="true"/>

<fieldType name="com_test" class="solr.TextField" positionIncrementGap="100">
   <analyzer>
      <tokenizer class="solr.KeywordTokenizerFactory"/>
      <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
 </fieldType>

【问题讨论】:

  • 你能发布你的相关schema.xml和solrconfig.xml
  • 问题是,如果在第一个单词上找到匹配项,则自动完成对第二个单词的效果很好。问题是整理加入了不是来自同一个文档的单词。而且我还没有找到任何可以正确匹配文档的内容。

标签: solr


【解决方案1】:

在谈到数据源和配置时,现有的 solr 建议器非常基础。无论是使用字段还是自定义字典,都由您来制作相应的来源。 如果您希望建议者能够生成正确的短语,最好的方法是将这些短语/单词元组索引在一起。

【讨论】:

  • 最后,我连接了我感兴趣的字段(在将它们发送到 Solr 之前)并根据连接提出建议。那么除了串联或自定义组件之外,没有其他方法可以实现这一点吗?
  • 我会将其标记为答案,因为最后我们将这些字段连接在一起以获得这些建议。所以,是的……
  • 无论如何你必须连接,要么在 SOLR 之前,要么为建议者开发自己的源。基于 FST 的 Suggester(您在上面使用的那个)通过从存储库中提取这些值来构建模型。因此,如果您不打算开发自己的存储库抽象 - 是的,最好做您已经做过的事情。
猜你喜欢
  • 2019-07-17
  • 1970-01-01
  • 2018-01-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多