Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.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
Autocomplete 通过木瓦和termvector组件自动完成_Autocomplete_Solr_N Gram - Fatal编程技术网

Autocomplete 通过木瓦和termvector组件自动完成

Autocomplete 通过木瓦和termvector组件自动完成,autocomplete,solr,n-gram,Autocomplete,Solr,N Gram,实现类似谷歌的自动完成的方法之一是在Solr1.4中结合使用木瓦和termvector组件 首先,我们使用带状图组件生成所有n-gram分布,然后使用termvector获得最接近用户术语序列的预测(基于文档频率) 模式: <fieldType name="shingle_text_fivegram" class="solr.TextField" positionIncrementGap="100"> <analyzer> <tokenize

实现类似谷歌的自动完成的方法之一是在Solr1.4中结合使用木瓦和termvector组件

首先,我们使用带状图组件生成所有n-gram分布,然后使用termvector获得最接近用户术语序列的预测(基于文档频率)

模式:

<fieldType name="shingle_text_fivegram" class="solr.TextField" positionIncrementGap="100">
    <analyzer>
        <tokenizer class="solr.LowerCaseTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="false" />
        <filter class="solr.ShingleFilterFactory" maxShingleSize="5" outputUnigrams="false"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>
</fieldType>
跳过剩下的

与其他Solr组件/过滤器结合使用是否可行

UPD:Lucene 4中有一种可能的解决方案(应该可以连接到SOLR中):

“难道你不能制作一个自定义的停止过滤器,只删除输入开始时的停止字(看到第一个标记)或结束时的停止字(之后没有看到非停止字标记)?这需要一些缓冲/状态保持(捕获/恢复测试),但似乎可行?”--Michael McCandless


from:

在Solr 1.4中,实现多字自动完成的最佳方法是使用EdgeNGramFilterFactory,因为您需要在用户输入时匹配用户输入。因此,您需要匹配“i”、“in”“ind”等来表示印度。

使用带有关键字TokenizerFactory的单独查询分析器,因此(使用您的示例):



问题不在于如何实现多字自动完成。这项工作已经完成。问题是,如何在搜索时在生成的n-gram的边缘放置停止词。感谢您的建议,我需要使用一些数据来测试这一点。
<searchcomponent name="termsComponent" class="org.apache.solr.handler.component.TermsComponent"/>
<requesthandler name="/terms" class="org.apache.solr.handler.component.SearchHandler">
    <lst name="defaults">
        <bool name="terms">true</bool>
        <str name="terms.fl">shingleContent_fivegram</str>
    </lst>
    <arr name="components">
        <str>termsComponent</str>
    </arr>
</requesthandler>
india
china
india and china
        <analyzer type="index">
            <tokenizer class="solr.LowerCaseTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="false" />
            <filter class="solr.ShingleFilterFactory" maxShingleSize="5" outputUnigrams="false"/>
            <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="false" />
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
        </analyzer>