2017-06-16 45 views
0

我試圖添加使用uax_url_email標記器的分析器將uax_url_email分析器添加到Elasticsearch 2.4.5

▶ elasticsearch --version 
Version: 2.4.5, Build: c849dd1/2017-04-24T16:18:17Z, JVM: 1.8.0_131 

curl -XPUT http://localhost:9200/timeline -H 'Content-Type: application/json' -d' 
{ 
    "settings": { 
     "analysis": { 
      "analyzer": { 
       "email_analyzer": { 
        "type": "custom", 
        "tokenizer": "uax_url_email" 
       } 
      } 
     } 
    } 
}' 

但是,這抱怨索引已經存在。

{ 
    "error": { 
     "index": "timeline", 
     "reason": "already exists", 
     "root_cause": [ 
      { 
       "index": "timeline", 
       "reason": "already exists", 
       "type": "index_already_exists_exception" 
      } 
     ], 
     "type": "index_already_exists_exception" 
    }, 
    "status": 400 
} 

所以,我想通過PATCH

curl -XPATCH http://localhost:9200/timeline -H 'Content-Type: application/json' -d' 
{ 
    "settings": { 
     "analysis": { 
      "analyzer": { 
       "email_analyzer": { 
        "type": "custom", 
        "tokenizer": "uax_url_email" 
       } 
      } 
     } 
    } 
}' 

這並不抱怨任何問題做一個更新,返回任何錯誤,因爲如果我發出了GET請求返回的輸出是一樣的到/timeline索引

輸出的有趣部分是設置沒有更新。

"settings": { 
     "index": { 
      "creation_date": "1497609042039", 
      "number_of_replicas": "1", 
      "number_of_shards": "5", 
      "uuid": "XaRS0KN1SLWcBsl6eLMZcg", 
      "version": { 
       "created": "2040599" 
      } 
     } 
    }, 

我也許錯期望新PATCHED分析對象是存在......

不知道我要去哪裏錯在這裏。

回答

1

您需要首先關閉索引,然後再次打開它:

curl -XPOST 'localhost:9200/timeline/_close' 

curl -XPUT 'localhost:9200/timeline/_settings' -d '{ 
    "analysis" : { 
    "analyzer":{ 
     "email_analyzer":{ 
     "type":"custom", 
     "tokenizer":"uax_url_email" 
     } 
    } 
    } 
}' 

curl -XPOST 'localhost:9200/timeline/_open'