Add ik participle under linux
1. Download the tokenizer installation package
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.1/elasticsearch-analysis-ik-5.5.1.zip
2. Unzip and install
1. Move elasticsearch-analysis-ik-5.5.1.zip to the plugins directory of the installation directory
mv elasticsearch-analysis-ik-5.5.1.zip /root/elasticsearch/elasticsearch-5.5.1/plugins/
2. Enter the plugins directory of the installation directory
cd /root/elasticsearch/elasticsearch-5.5.1/plugins/
3. Unzip
unzip elasticsearch-analysis-ik-5.5.1.zip
4. Delete the compressed package
rm -rf elasticsearch-analysis-ik-5.5.1.zip
According to the official instructions, it has been successfully installed at this time, just restart ElasticSearch.
3. Test
Using the postman tool
Expand your own participle:
my.dic
Xiaomi phone
Huawei cell phone
Other query statements:
cluster health
curl -X GET 'http://localhost:9200/_cluster/health?pretty=true'
Elasticsearch has a feature called aggregations that allow you to generate complex analytics statistics on your data. It is much like GROUP BY in SQL but more powerful.
Format of megacorp/employee:
{ "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests" : [ "sports", "music" ] }
Find out what all the staff have in common (hobbies):
{ "aggs": { "all_interests": { "terms": { "field": "interests.keyword" } } } }
Statistics on the average age of staff under each interest:
curl -X GET 'http://localhost:9200/megacorp/employee/_search?pretty=true' -d ' { "aggs" : { "all_interests" : { "terms" : { "field" : "interests.keyword" }, "aggs" : { "avg_age" : { "avg" : { "field" : "age" } } } } } }’
Combine multiple clauses
{ "query": { "bool": { "must": { "match": { "first_name": "doublas" } }, "must_not": { "match": { "last_name": "roger" } } } } }
Add filter conditions to the query statement:
{ "query": { "bool": { "filter": { "term": { "first_name": "john" } }, "must": { "match": { "last_name": "smith" } } } } }
The query is highlighted:
{ "query":{ "match":{ "about":"rock climbing" } }, "highlight":{ "pre_tags":["<font color='red'>"], "post_tags":["</font>"], "fields":{ "about":{} } } }