2016-11-08 215 views
0

任何人都可以建議我使用索爾的最佳方式,我的產品定期搜索,也應支持同義詞&模糊搜索嗎?索爾索引與搜索

想,如果我有一句話CRO搜索,我需要的產品的任何地方開始結痂,然後痂出現在場上,然後同義詞&然後在其上的模糊在相應的提高

回答

0

我有我的項目的情況。

我使用一起FuzzyLookupFactory(具有多個建議者)和AnalyzingInfixLookupFactory。我正在使用solrj(java api)進行請求查詢。

首先我搜索詞與analyzeinfixlookupfactory這可以找到字在字段中的任何地方,但你必須正確輸入。例如產品名稱「東芝」如果你搜索「胡說」它可以找到「東芝」正確,但是如果你搜索「TOSHBA」它不會找到任何產品。

這次我使用fuzzylookupfactory建議我拆分所有單詞(例如,你有「東芝筆記本電腦」word1 =東芝word2 =筆記本電腦等),並一對一搜索和模糊將找到TOSBA - >東芝,找到東芝後再次使用analyzeinfixlookupfactory查找完整的產品字段。

比如你要找到「東芝筆記本電腦」,然後搜索「TOSHBA laptp」。首先嚐試「analyzeinfixlookupfactory」並且響應將爲空。響應null搜索模糊每個單詞並添加你發現的東西像toshba - > toshiba + laptp-> laptop它將toshiba筆記本電腦,現在你可以再次搜索analyzeinfixlookupfactory完整的字段。

在(solrconfig.xml中)我的分析建議者

<searchComponent name="suggestAnalyzing" class="solr.SuggestComponent"> 
<lst name="suggester"> 
<str name="name">suggestAnalyzing</str> 
<str name="lookupImpl">AnalyzingInfixLookupFactory</str> 
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str> 
<str name="storeDir">suggester_fuzzy_dir</str> 
<str name="indexPath">suggester_infix_dir</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">COMPLETE_FIELD</str> 
<str name="suggestAnalyzerFieldType">textgen</str> 

<float name="threshold">0.005</float> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 


</searchComponent> 

<requestHandler name="/suggestAnalyzing" class="solr.SearchHandler"> 
<lst name="defaults"> 
<str name="suggest.dictionary">suggestAnalyzing</str> 
<str name="suggest">true</str> 
<str name="suggest.count">10</str> 

</lst> 
<arr name="components"> 
<str>suggestAnalyzing</str> 
</arr> 
</requestHandler> 

我模糊的建議者在(solrconfig.xml中)

<searchComponent class="solr.SuggestComponent" name="suggest"> 

<lst name="suggester"> 
<str name="name">word1suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word1</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 

<lst name="suggester"> 
<str name="name">word2suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word2</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="indexPath">suggestions/word2suggester</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 

<lst name="suggester"> 
<str name="name">word3suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word3</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="indexPath">suggestions/word3suggester</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="preserveSep">true</str> 
<str name="preservePositionIncrements">true</str> 
<str name="exactMatchFirst">true</str> 
<float name="threshold">0.005</float> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 

</lst> 

<lst name="suggester"> 
<str name="name">word4suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word4</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="indexPath">suggestions/word4suggester</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="preserveSep">true</str> 
<str name="preservePositionIncrements">true</str> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 

<lst name="suggester"> 
<str name="name">word5suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word5</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="indexPath">suggestions/word5suggester</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="preserveSep">true</str> 
<str name="preservePositionIncrements">true</str> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 

<lst name="suggester"> 
<str name="name">word6suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word6</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="indexPath">suggestions/word6suggester</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="preserveSep">true</str> 
<str name="preservePositionIncrements">true</str> 
<str name="exactMatchFirst">true</str> 
<float name="threshold">0.005</float> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 


<lst name="suggester"> 
<str name="name">word7suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word7</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="indexPath">suggestions/word7suggester</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="preserveSep">true</str> 
<str name="preservePositionIncrements">true</str> 
<str name="exactMatchFirst">true</str> 
<float name="threshold">0.005</float> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 

<lst name="suggester"> 
<str name="name">word8suggester</str> 
<str name="lookupImpl">FuzzyLookupFactory</str> 
<str name="dictionaryImpl">DocumentDictionaryFactory</str> 
<str name="field">word8</str> <!-- the indexed field to derive suggestions from --> 
<str name="suggestAnalyzerFieldType">textgen</str> 
<str name="indexPath">suggestions/word8suggester</str> 
<str name="storeDir">suggest_fuzzy_doc_expr_dict</str> 
<str name="preserveSep">true</str> 
<str name="preservePositionIncrements">true</str> 
<str name="exactMatchFirst">true</str> 
<float name="threshold">0.005</float> 
<str name="buildOnStartup">false</str> 
<str name="buildOnCommit">false</str> 
</lst> 


</searchComponent> 

<requestHandler class="solr.SearchHandler" name="/suggest"> 
<lst name="defaults"> 
<str name="spellcheck">true</str> 
<str name="suggest">true</str> 
<str name="suggest.dictionary">word1suggester</str> 
<str name="suggest.dictionary">word2suggester</str> 
<str name="suggest.dictionary">word3suggester</str> 
<str name="suggest.dictionary">word4suggester</str> 
<str name="suggest.dictionary">word5suggester</str> 
<str name="suggest.dictionary">word6suggester</str> 
<str name="suggest.dictionary">word7suggester</str> 
<str name="suggest.dictionary">word8suggester</str> 

<str name="spellcheck.count">10</str> 

</lst> 
<arr name="components"> 
<str>suggest</str> 
</arr> 
</requestHandler> 

我的託管架構字段

<fieldType name="textgen" class="solr.TextField" positionIncrementGap="100"> 
<analyzer type="index"> 
<tokenizer class="solr.WhitespaceTokenizerFactory"/> 
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/> 
<filter class="solr.LowerCaseFilterFactory"/> 
</analyzer> 
<analyzer type="query"> 
<tokenizer class="solr.WhitespaceTokenizerFactory"/> 
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> 
<filter class="solr.StopFilterFactory" 
     ignoreCase="true" 
     words="stopwords.txt" 

     /> 
<filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/> 
<filter class="solr.LowerCaseFilterFactory"/> 
</analyzer> 
</fieldType> 

<field name="word1" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/> 

<field name="COMPLETE_FIELD" type="textgen" multiValued="true" indexed="true" stored="true"/> 

<field name="word2" type="text_general" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/> 

<field name="word3" type="text_general" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/> 

<field name="word4" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/> 

<field name="word5" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/> 

<field name="word6" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/> 

<field name="word7" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/> 
<field name="word8" type="textgen" omitNorms="true" omitTermFreqAndPositions="true" multiValued="true" indexed="true" stored="true"/>