Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

60.4. Plugin 插件管理

60.4.1. 手工安裝插件

cd /usr/local/src/
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v1.9.4/elasticsearch-analysis-ik-1.9.4.zip
cd /usr/share/elasticsearch/plugins
mkdir ik
cd ik
unzip /usr/local/src/elasticsearch-analysis-ik-1.9.4.zip

/etc/init.d/elasticsearch restart
			

60.4.2. plugin 命令

plugin -install medcl/elasticsearch-analysis-ik/1.9.0 			
			

60.4.3. 插件測試

			
curl -XDELETE http://localhost:9200/information/news/_mapping?pretty
curl -XDELETE http://localhost:9200/information/?pretty

curl -XPUT http://localhost:9200/information
curl -XPOST http://localhost:9200/information/news/_mapping?pretty -d'
{
    "news": {
            "_all": {
            "analyzer": "ik_max_word",
            "search_analyzer": "ik_max_word",
            "term_vector": "no",
            "store": "false"
        },
        "properties": {
            "content": {
                "type": "string",
                "store": "no",
                "term_vector": "with_positions_offsets",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word",
                "include_in_all": "true",
                "boost": 8
            }
        }
    }
}'

curl -XPOST http://localhost:9200/information/news/ -d'
{"title": "越南胡志明遊記·教堂·管風琴的天籟之音","content":"這是我平生第一次去教堂,也是第一次完整的參加宗教儀式。當我駐足教堂外的時候,耳邊傳來天籟之音,是管風琴,確切的說是電子風琴。真正的管風琴造價昂貴,管風琴通常需要根據教堂尺寸定製,無法量產。我記得中國只有4座管風琴,深圳音樂廳有一座。"}
'
curl -XPOST http://localhost:9200/information/news/ -d'
{"title": "越南胡志明遊記·信仰·法事","content":"佛經的形成過程是與佛教的發展相始終的,按照佛教發展的時間順序,最早形成的是小乘佛教三藏,之後形成的是大乘佛教三藏,最後形成的是密宗三藏。"}
'

curl -XPOST http://localhost:9200/information/news/_search  -d'
{
    "query" : { "term" : { "content" : "佛經" }},
    "highlight" : {
        "pre_tags" : ["<strong>", "<strong>"],
        "post_tags" : ["</strong>", "</strong>"],
        "fields" : {
            "content" : {}
        }
    }
}'		

curl -XPOST http://localhost:9200/information/news/_search  -d'
{
    "query" : { "term" : { "content" : "中國" }},
    "highlight" : {
        "pre_tags" : ["<b>", "<i>"],
        "post_tags" : ["</b>", "</i>"],
        "fields" : {
            "content" : {}
        }
    }
}'