Elasticsearch cluster &&ik word breakers && synonyms

Source: Internet
Author: User

wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.3/ Elasticsearch-2.3.3.tar.gz



Cluster installation:

Three nodes: MASTER,SLAVE1,SLVAE2



VI elasticsearch.yml


Cluster.name:my-application

Node.name:node-3 (node-unique name, note uniqueness)

network.host:192.168.137.117

http.port:9200

Discovery.zen.ping.unicast.hosts: ["Master", "slave1", "Slave2"]





Installing plugins

/home/qun/soft/elasticsearch-2.3.3/bin/plugin Install Analysis-icu

/home/qun/soft/elasticsearch-2.3.3/bin/plugin Install Mobz/elasticsearch-head

Marvel

/home/qun/soft/elasticsearch-2.3.3/bin/plugin Install license

/home/qun/soft/elasticsearch-2.3.3/bin/plugin Install Marvel-agent



Execute on each node:

Elasticsearch-d



Kill node

Kill-9 ' Ps-ef|grep Elasticsearch|awk ' {print $} '


Start

/home/qun/soft/elasticsearch-2.3.3/bin/elasticsearch-d



To access the cluster:

http://master:9200/_plugin/head/


A node is a Elasticsearch instance, and a cluster (cluster) consists of one or more nodes that have the same cluster.name.

They work together to share data and load. When a new node is added or a node is deleted, the cluster perceives and balances the data.



As a user, we are able to communicate with any node in the cluster, including the master node. Each node knows which node the document exists on, and they can forward the request to the appropriate node.

The node we are accessing is responsible for collecting the data returned by each node and finally returning it to the client. All this is handled by Elasticsearch.


Get cluster status

http://master:9200/_cluster/health/


{"Cluster_Name": "My-application", "status": "Green", "timed_out": false, "Number_of_nodes": 3, "Number_of_data_nodes" : 3, "active_primary_shards": Active_shards, "Relocating_shards": 0, "Initializing_shards": 0, "unassigned_ Shards ": 0," Delayed_unassigned_shards ": 0," Number_of_pending_tasks ": 0," Number_of_in_flight_fetch ": 0," Task_max_ Waiting_in_queue_millis ": 0," Active_shards_percent_as_number ": 100}




Setting up Add shards

Put/blogs/_settings

{

"Number_of_replicas": 2

}




Delete Index

Curl-xdelete ' http://master:9200/.marvel-es-1-2016.05.29 '

Curl-xdelete ' Http://master:9200/.marvel-es-data-1 '






Installing the IK word breaker (Https://github.com/medcl/elasticsearch-analysis-ik)

wget Https://github.com/medcl/elasticsearch-analysis-ik/archive/master.zip


MVN Package

Mkdir-p/home/qun/soft/elasticsearch-2.3.4/plugins/ik

cp/home/qun/soft/elasticsearch-2.3.3/elasticsearch-analysis-ik-master/target/releases/ Elasticsearch-analysis-ik-1.9.3.zip/home/qun/soft/elasticsearch-2.3.3/plugins/ik

Unzip Elasticsearch-analysis-ik-1.9.3.zip


Test participle

/twitter/_analyze?analyzer=standard&pretty=true&text=, I'm Chinese.

/twitter/_analyze?analyzer=ik&pretty=true&text=, I'm Chinese.



To add a user-defined dictionary:

Elasticsearch-2.3.3/plugins/ik/config/ikanalyzer.cfg.xml

Chestnuts: add sougou.dic, semicolon delimited, relative path, restart ES cluster

<entry key= "Ext_dict" >custom/mydict.dic;custom/single_word_low_freq.dic;custom/sougou.dic</entry>


<?xml version= "1.0" encoding= "UTF-8"? ><! DOCTYPE Properties SYSTEM "Http://java.sun.com/dtd/properties.dtd" ><properties><comment>ik Analyzer Extended configuration </comment><!--users can configure their own extension dictionaries here--><entry key= "Ext_dict" >custom/mydict.dic;custom/single_ Word_low_freq.dic;custom/sougou.dic</entry> <!--users can configure their own extension stop word dictionary--><entry key= "Ext_stopwords" >custom/ext_stopword.dic</entry><!--Users can configure the remote extension dictionary here--><!--<entry key= "Remote_ext_dict" > words_location</entry>--><!--User can configure the remote extension Stop word dictionary here--><!--<entry key= "Remote_ext_stopwords" >words_location</entry>--></properties>





Configure synonyms

Modify: Elasticsearch-2.3.3/config/elasticsearch.yml, add the following at the end of the text

Index:analysis:analyzer:ik_syno:type:custom tokenizer:ik_max_word filter: [My_sy    Nonym_filter] Ik_syno_smart:type:custom tokenizer:ik_smart filter: [My_synonym_filter] Filter:my_synonym_filter:type:synonym Synonyms_path:analysis/synonym.txt



To add a dictionary:

Mkdir-p elasticsearch-2.3.3/config/analysis

VI Elasticsearch-2.3.3/config/analysis/synonym.txt

ipod, i-pod, I pod

Foozball, Foosball

Universe, Cosmos

Tomato, tomato

Potatoes, potatoes



Test synonyms:

get/iktest/_analyze?analyzer=ik_syno_smart&pretty=true&text= potato tomatoes

Results:

{"Tokens": [{"token": "Potato", "Start_offset": 0, "End_offset": 3, "type": "Cn_word", "position": 0},{"token": "Potato", "Start_ Offset ": 0," End_offset ": 3," type ":" synonym "," position ": 0},{" token ":" Tomato "," start_offset ": 3," End_offset ": 6," type ": "Cn_word", "position": 1},{"token": "Tomato", "start_offset": 3, "End_offset": 6, "type": "synonym", "position": 1}]}


Elasticsearch cluster &&ik word breakers && synonyms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.