Note: Elasticsearch version: 1.4.2
First, installation and configuration
1. Download Elasticsearch-analysis-ik-master.zip from Https://github.com/medcl/elasticsearch-analysis-ik
2. Unzip the Elasticsearch-analysis-ik-master.zip
Unzip Elasticsearch-analysis-ik-master.zip
3. enter Elasticsearch-analysis-ik-master, compile the source code
CD Elasticsearch-analysis-ik-master
MVN Clean Install-dmaven.test.skip=true
4. Create Analysis-ik under the $es_home/plugins folder
mkdir Analysis-ik
5. Move the compiled elasticsearch-analysis-ik-1.2.9.zip to $es_home/plugins/analysis-ik and unzip.
Build location of post-compilation Elasticsearch-analysis-ik-1.2.9.zip
6. Copy the Ik folder under config to $es_home/config/
7. Modify $es_home/config/elasticsearch.yml
Index Analysis Analyzer Ik Alias: [Ik_analyzer] Type:org.elasticsearch.index.analysis.IkAnalyzerProvider Ik_max_word: Type:ik Use_smart:false Ik_smart: Type:ik Use_smart:true #或 Index.analysis.analyzer.ik.type: "Ik" |
8. Restart Elasticsearch
Second, the test
1. Create Indexes Index
Curl-xput Http://localhost:9200/index
2. Create mapping
Curl-xpost http://localhost:9200/index/fulltext/_mapping-d '
{
"Fulltext": {
"_all": {
"Indexanalyzer": "Ik",
"Searchanalyzer": "Ik",
"Term_vector": "No",
"Store": "false"
},
"Properties": {
"Content": {
' Type ': ' String ',
"Store": "No",
"Term_vector": "With_positions_offsets",
"Indexanalyzer": "Ik",
"Searchanalyzer": "Ik",
"Include_in_all": "true",
"Boost": 8
}
}
}
}‘
3. Index some data
Curl-xpost HTTP://LOCALHOST:9200/INDEX/FULLTEXT/1-d '
{"Content": "Tohoku University is a state key university directly under the Ministry of Education, located in the northeast Central city of Shenyang." The school occupies a total area of 2.61 million square meters, building area of 1.23 million square meters. "}
‘
Curl-xpost HTTP://LOCALHOST:9200/INDEX/FULLTEXT/2-d '
{"Content": "Northeastern University established in Qinhuangdao." The Tohoku University Qinhuangdao Branch was formally approved by the Ministry of Education. "}
‘
Curl-xpost HTTP://LOCALHOST:9200/INDEX/FULLTEXT/3-d '
{"Content": "Northeastern University Qinhuangdao branch is formally approved by the Ministry of Education, in the unified planning of northeastern universities, for the national enrollment, relatively independent school of the general higher education." Founded in 1987, the school is an integral part of Northeastern University. "}
‘
Curl-xpost HTTP://LOCALHOST:9200/INDEX/FULLTEXT/4-d '
{"Content": "Neusoft English name Neusoft, Neusoft is China's leading IT solutions and service provider." In 1991, Neusoft was founded in northeastern China University. The company's main business areas include: industry solutions, product engineering solutions and related software products, platforms and services. "}
‘
4. Enquiry
Curl-xpost http://localhost:9200/index/fulltext/_search-d '
{
"Query": {"term": {"Content": "Northeastern University"}},
"Highlight": {
"Pre_tags": ["<tag1>", "<tag2>"],
"Post_tags": ["</tag1>", "</tag2>"],
"Fields": {
"Content": {}
}
}
}
‘
5. Search by Kibana4.0
① first modify the configuration, then click the Edit button:
② Adding a new configuration
Cancel the index contains time-based events
In index name of pattern, enter "index", click Create
③ back to the query interface, select Index to query.
Reference: Https://github.com/medcl/elasticsearch-analysis-ik
Install Chinese word segmentation ik for elasticsearch