我配置了以下solr字段,並希望瞭解如何從搜索中消除某些單詞。例如薯條,油炸等。我試圖把它放在stopwords.txt,但不起作用solr仍然返回結果。 我的另一個問題是。排除solr搜索中的單詞或短語
如何限制搜索,例如,如果文本包含兩個詞都接近或分離,它應該返回匹配了如
結果如果我要尋找的蝦poboy它應該返回1和3,而不是2
- 我最喜歡蝦poboy
- 蝦蔬菜
大蝦三明治下poboy三明治類
<fieldType name="text" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.WhitespaceTokenizerFactory"/> <!--tokenizer class="solr.KeywordTokenizerFactory"/--> <filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.PatternReplaceFilterFactory" pattern="(;|,|-)\s*" replacement=" " replace="all"/> <filter class="solr.PatternReplaceFilterFactory" pattern="^(\p{Punct}*)(.*?)(\p{Punct}*)$" replacement="$2"/> <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" preserveOriginal="1" /> <filter class="solr.TrimFilterFactory"/> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.keyword.txt" ignoreCase="true" expand="true" tokenizerFactory="solr.KeywordTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> <filter class="solr.PorterStemFilterFactory"/> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.WhitespaceTokenizerFactory"/> <!--tokenizer class="solr.KeywordTokenizerFactory"/--> <filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.PatternReplaceFilterFactory" pattern="(;|,|-)\s*" replacement=" " replace="all"/> <filter class="solr.PatternReplaceFilterFactory" pattern="^(\p{Punct}*)(.*?)(\p{Punct}*)$" replacement="$2"/> <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" preserveOriginal="1" /> <filter class="solr.TrimFilterFactory"/> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.keyword.txt" ignoreCase="true" expand="true" tokenizerFactory="solr.KeywordTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/> <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/> <filter class="solr.PorterStemFilterFactory"/> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> </analyzer> </fieldType>
我嘗試了你建議的方法,所以如果我只是搜索薯條,沒有什麼是可以返回的,但如果我搜索 炒飯,排除油炸但只搜索大米。有什麼建議麼? – user357086