Apache solr 搜索部分词 [英] Apache solr search part of the word

查看:36
本文介绍了Apache solr 搜索部分词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 apache solr 搜索引擎为我的网站数据库编制索引..

I'm using apache solr search engine for indexing my website database..

我正在使用 django+http://haystacksearch.org/

I'm using django+http://haystacksearch.org/

假设我有一个包含Chicken"字样的文档

So let's say I have document that have word "Chicken"

当我搜索chicken"时——solr可以找到这个文档

When I search for "chicken" - solr can find this document

但是当我搜索小鸡"时 - 它没有找到任何东西..

But When I search "chick" - it does not find anything..

有没有办法解决这个问题?

Is there a way to fix this ?

推荐答案

注意:以下解决方案是 Solr 1.4 (及更高版本) 特定的!

Note: The following solution is Solr 1.4 (and above) specific!

为了获得更大的灵活性,我建议使用 NGramTokenizerFactory 进行完整的前后通配符搜索.如果您只想在字符串的开头或结尾搜索子字符串,请考虑使用 EdgeNGramTokenizerFactory.

For more flexibility, I would recommend indexing your data with the NGramTokenizerFactory to do complete front and back wildcard searches. If you just want to search for substrings at the beginning or end of the string, consider using the EdgeNGramTokenizerFactory.

这里有一个可以满足您需要的文本字段类型的替换:

Here's a drop in replacement of the text field type which would accomodate your need:

<fieldType name="text" class="solr.TextField" >
<analyzer type="index">
    <tokenizer class="solr.NGramTokenizerFactory" minGramSize="3" maxGramSize="15" />
    <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory" />
    <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

这篇关于Apache solr 搜索部分词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆