您好,登錄后才能下訂單哦!
這篇文章主要介紹“Solr4.7的synonyms怎么配置”,在日常操作中,相信很多人在Solr4.7的synonyms怎么配置問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Solr4.7的synonyms怎么配置”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!
在搜索中,往往需要用到關(guān)聯(lián)詞(近義詞),比如,搜索 “聯(lián)想” 品牌那么我們同時(shí)搜索 “l(fā)enovo”等,solr為我們提供了近義詞過(guò)濾器solr.SynonymFilterFactory。
配置搜索近義詞很簡(jiǎn)單,只要在schema字段定義過(guò)濾器
在schema.xml的<types>標(biāo)簽中添加<fieldType>,如下:
<!-- IK中文分詞器,停用詞,同義詞配置 --> <fieldType name="text_ik" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" /> <filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="org.wltea.analyzer.lucene.IKTokenizerFactory" /> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false" /> <filter class="solr.LowerCaseFilterFactory"/> <filter class="solr.RemoveDuplicatesTokenFilterFactory"/> </analyzer> </fieldType>
solr.SynonymFilterFactory配置中,synonyms是近義詞配置文件
ignoreCase:為true,表示轉(zhuǎn)化為小寫(xiě)匹配,及忽略大小寫(xiě)。
expand:涉及到synonyms.txt的配置
synonyms.txt配置一行為單位,建立關(guān)鍵詞聯(lián)系
# The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #----------------------------------------------------------------------- #some test synonym mappings unlikely to appear in real input text aaafoo => aaabar bbbfoo => bbbfoo bbbbar cccfoo => cccbar cccbaz fooaaa,baraaa,bazaaa # Some synonym groups specific to this example GB,gib,gigabyte,gigabytes MB,mib,megabyte,megabytes Television, Televisions, TV, TVs #notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming #after us won't split it into two words. 中國(guó),英國(guó),日本 # Synonym mappings can be used for spelling correction too pixima => pixma
就是說(shuō)=>指一對(duì)一,以逗號(hào)分隔的是組群,也就是多對(duì)多。
當(dāng)然這個(gè)還得定義相關(guān)字段為這個(gè)類(lèi)型,如下。
<field name="msg_title" type="text_ik" indexed="true" stored="true"/>
到此,關(guān)于“Solr4.7的synonyms怎么配置”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。