问题描述
我遇到需要同时使用 EdgeNGramFilterFactory 和 NGramFilterFactory 的情况.
I have a situation where I need to use both EdgeNGramFilterFactory and NGramFilterFactory.
我正在使用 NGramFilterFactory 执行包含"样式搜索,最小字符数为 2.我还想搜索第一个字母,例如带有前端 EdgeNGramFilterFactory 的startswith".
I am using NGramFilterFactory to perform a "contains" style search with min number of characters as 2. I also want to search for the first letter, like a "startswith" with a front EdgeNGramFilterFactory.
我不想将 NGramFilterFactory 降低到最少 1 个字符,因为我不想索引所有字符.
I dont want to lower the NGramFilterFactory to min characters of 1 as I dont want to index all characters.
非常感谢您的帮助
干杯
推荐答案
你不一定要在同一个领域做所有这些.我会为每种处理使用不同的自定义类型创建不同的字段,以便您可以单独应用逻辑.
You don't necessarily have to do all this in the same field. I would create a different fields using different custom types for each treatment so that you can apply the logic separately.
如下:
text包含原始标记,经过最少处理;text_ngram使用 NGramFilter 处理最少两个字符的标记text_first_letter使用 EdgeNGram 作为单字符首字母标记
textcontains the original tokens, minimally processed;text_ngramuses the NGramFilter for your two-character-minimum tokenstext_first_letteruses EdgeNGram for your one-character initial-letter tokens
如果您以这种方式处理所有 text 字段,那么您也许可以使用 copyField 来填充字段.否则,您可以指示 Solr 客户端为三种不同的字段类型发送相同的字段值.
If you're processing all text fields in this way, then you might be able to get away with using a copyField to populate the fields. Otherwise, you can instruct your Solr client to send in the same field values for the three separate field types.
搜索时,使用 qf 参数将所有这些都包含在搜索中.
When searching, include all of them in your searches with the qf parameter.
<fieldType name="text" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<fieldType name="text_ngram" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.NGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/>
</analyzer>
</fieldType>
<fieldType name="text_first_letter" class="solr.TextField" positionIncrementGap="100">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StandardFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="1" side="front"/>
</analyzer>
</fieldType>
设置 field 和 dynamicField 定义由您决定.或者,如果您有更多问题,请告诉我,我可以进行编辑并进行澄清.
Setting up field and dynamicField definitions are left up to you. Or let me know if you have more questions and I can edit with clarifications.
这篇关于Solr:结合 EdgeNGramFilterFactory 和 NGramFilterFactory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)