2012-03-18 33 views
2

我正在为我的应用程序创建文章搜索功能。我正在寻找类似于创建新问题时在标题文本框下弹出的Stackoverflow的问题创建建议的搜索功能。如何配置Solr以生成最常用单词的结果集

搜索字符串:

"the dog waker" 

数据库行:

"The best you can do" 
"Love to your pet" 
"Selina the dog walker" 
"How to teach your dog to be healthy" 
"Teach your dog tricks" 

我想在输入每个字,使对结果集,如果输入字的影响尚未发现它不过滤掉我正在搜索的数据集。

我要得到这个结果集:

"Selina the dog walker" - 有“狗”模糊搜索“行者”从输入“之杖”
"How to teach your dog to be healthy" - 有“狗”
"Teach your dog tricks" - 有“狗”

我用以下修改了schema.xml,但它似乎没有正常工作。它滤除了一切,除非我拥有所有的词。

<analyzer> 
    <tokenizer class="solr.StandardTokenizerFactory"/> 
    <filter class="solr.LowerCaseFilterFactory"/> 
    <filter class="solr.StopFilterFactory"/>  -->  
    <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/> 
</analyzer> 
+0

不确定你想要做什么,你希望被忽略的行出现在结果中? – 2012-03-19 13:53:43

+0

我想获得结果集,因为这三行中有“狗”,而“Selina the dog walker”有“walker”。我想忽略其他两个,因为他们没有我在输入搜索字符串中的任何单词 – EverTheLearner 2012-03-19 18:36:20

回答

1

不知道你要在这里做什么,但我会删除EdgeNGramFilterFactory,如果你想添加一些fuzzyness,你可以添加一个PhoneticFilter或使用Lucene的语法〜

0

不确定:

<filter class="solr.StopFilterFactory"/> 

(顺便说一句,你知道,你在这行的最后一个结束的XML注释)

在另一方面,我知道,在Solr的4,弗洛机翼的工作原理:

<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt " enablePositionIncrements="true"/> 

我不认为你需要:

<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/> 

最后,“爱你的宠物”不应该在结果中显示,你确认?