我的數(shù)據(jù)是關(guān)聯(lián)數(shù)據(jù)庫(kù)的怀估,剛?cè)肟佑玫淖詭У姆衷~损姜,所有的中文都會(huì)被分成單個(gè)条获。很不好用
而更換IK分詞器后忠荞,發(fā)現(xiàn)不生效,百度后是 沒(méi)有建立? 索引(mapping)帅掘。所以想要進(jìn)行更換委煤,結(jié)果在創(chuàng)建的時(shí)候,報(bào)沖突錯(cuò)誤修档。
本來(lái)想整個(gè)報(bào)錯(cuò)圖給你們看下碧绞,找不到了。直接解決錯(cuò)誤吧
在數(shù)據(jù)已有的情況下吱窝,再次導(dǎo)入是一個(gè)不合適的方法讥邻,而我們想要更新mapping就會(huì)有沖突,解決思路就是院峡,新建一個(gè)索引庫(kù)兴使,然后數(shù)據(jù)同步過(guò)去,再刪除原有的照激。本以為會(huì)很難发魄,結(jié)果很簡(jiǎn)單
1:建立新的索引
PUT myindex? ? ? ??
2:新建索引結(jié)構(gòu)??
?POST myindex/_mapping
{
? "properties": {
? ? "content":{
? ? ? "type": "text",
? ? ? "analyzer": "ik_max_word",
? ? ? ? ? ? ? ? "search_analyzer": "ik_smart",
? ? ? ? ? ? ? ? "index_options": "docs"
? ? },
? ? "title":{
? ? ? "type": "text",
? ? ? "analyzer": "ik_max_word",
? ? ? ? ? ? ? ? "search_analyzer": "ik_smart",
? ? ? ? ? ? ? ? "index_options": "docs"
? ? }
? }
}
3:數(shù)據(jù)替換?
POST _reindex
{
? "source": {
? ? "index":"index"
? },
? "dest": {
? ? "index": "myindex"
? }
}
4. 查看數(shù)據(jù)是否已同步到新的索引上
GET /myindex/_search
至此數(shù)據(jù)索引替換完成。在替換索引之前的入庫(kù)粒度還是按照原有的單個(gè)中文实抡,但是查詢時(shí)會(huì)按照IK分詞器的欠母,所以可以正常使用