问题描述
我正在使用apache solr搜索引擎来索引我的网站数据库。我正在使用django +
所以让我们说我有文字鸡 p>
当我搜索鸡 - solr可以找到这个文件
但是当我搜索小鸡 - 它没有找到任何东西..
有没有办法解决这个问题?
注意:以下解决方案是Solr 1.4
我建议使用进行完整的前后通配符搜索。如果您只想在字符串的开头或结尾搜索子字符串,请考虑使用。
这是一个替换文本字段类型,可以满足您的需求:
< fieldType name =textclass =solr.TextField>
< analyzer type =index>
< tokenizer class =solr.NGramTokenizerFactoryminGramSize =3maxGramSize =15/>
< filter class =solr.LowerCaseFilterFactory/>
< / analyzer>
< analyzer type =query>
< tokenizer class =solr.WhitespaceTokenizerFactory/>
< filter class =solr.LowerCaseFilterFactory/>
< / analyzer>
< / fieldType>
I'm using apache solr search engine for indexing my website database..
I'm using django+http://haystacksearch.org/
So let's say I have document that have word "Chicken"
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 ?
Note: The following solution is Solr 1.4 (and above) specific!
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搜索部分的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!