Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Solr 基于第一个单词上的匹配文档的多单词建议_Solr - Fatal编程技术网

Solr 基于第一个单词上的匹配文档的多单词建议

Solr 基于第一个单词上的匹配文档的多单词建议,solr,Solr,我正在使用Solr4.6,我试图让Solr根据多个单词给我自动完成的建议。我使用spellcheck.collate实现了这一点,但我现在面临的问题是,它返回与搜索无关的建议(搜索基于汽车) 每个文档都有多个字段(品牌、型号、车身颜色等)。我试图实现的是让solr只返回第二个单词的建议,这些建议与基于第一个单词的匹配文档中的字段相匹配 我想我可以使用Solr库在Java中编写一个自定义组件并将其插入,但我想肯定有一种更简单的方法可以使用Solr已经知道的东西来实现这一点 注意:我已经研究Solr

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

每个文档都有多个字段(品牌、型号、车身颜色等)。我试图实现的是让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>

com_测试
org.apache.solr.spelling.Suggester
org.apache.solr.spelling.suggest.fst.FSTLookup
com_测试
真的
真的
com_测试
10
真的
com_测试
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>

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

您可以发布相关的schema.xml和solrconfig.xml吗?问题是,如果自动完成功能在第一个单词上找到匹配项,则第二个单词的自动完成功能可以正常工作。问题是collate连接的单词不是来自同一文档。我还没有找到任何与文档匹配的内容。最后,我将感兴趣的字段连接在一起(在发送给Solr之前),并根据连接提出建议。除了连接或自定义组件之外,没有其他方法可以实现这一点吗?我将把它标记为一个答案,因为最终我们将字段连接在一起以获得这些建议。所以,是的…无论如何,你必须连接,要么在SOLR之前,要么为suggester开发你自己的源代码。基于FST的Suggester(您上面使用的那个)通过从存储库中提取这些值来构建模型。因此,如果您不打算开发自己的存储库抽象——是的,最好做您已经做过的事情。
<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>