Recently, there is a business need, that is, full-text search keyword query list, and thus to Es learning, also learned half a month, to do a note, summed up their own learning process.
Learning a new technology alone, always inevitably take a lot of detours, in this recommendation Es Basic tutorial, right, learn the official website tutorial can be.
1) Elasticsearch: Authoritative guide
Https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html
The authoritative Chinese course, for the English poor classmate, read this tutorial can get started quickly.
2) Elasticsearchreference official website English Course
Https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
Really want to thoroughly understand ES or read more English official documents, Knowledge point is the most comprehensive. ES version Selection
Said ES version of the choice, when beginners es, Most of the information found is for the 2.x version, this is intended to use the 2.x version, but read the es5.x version of the new feature description, decisive or use 5.x version, because the new version of ES performance than 2.x version is much better, but also want to use Spring-data-elasticsearch, but SPR The Ing-data does not support the 5.x version, and ES has a strong momentum of 5.5.0, which was used half a month ago and has now been updated to 5.5.1. ES client Request mode
1) Java API: Create Transportclient, recommended for complex applications
2) Java REST Client: Create Restclient
3) HTTP RESTful API: Access using the most original HTTP request
Currently used for the third, the reason ES business needs a single, do not need to dynamically create, delete the index, easy to use, only need to learn ES rest syntax can be. In fact later can be switched to restclient, it is persistent HTTP link (using httpclient also need an HTTP connection pool), features such as the official said:
The low-level client ' s features include:
Minimal dependencies load balancing across all available nodes failover in case of node failures and upon specific respons E Codes failed Connection penalization (whether a failed node is retrieddepends on how many consecutive times it failed; t He more failed attempts Thelonger the client would wait before trying that same node again) persistent Connections Trace Lo Gging of requests and responses optional automatic discovery of cluster nodes
es Common Plugins
1) Head Plugin
5.5 Using Tutorial: http://www.cnblogs.com/xing901022/p/6030296.html
2) IK Chinese parser – Chinese word breaker is required, can be customized dictionary
GitHub Address: Https://github.com/medcl/elasticsearch-analysis-ik
Plugin Download Address: https://github.com/medcl/elasticsearch-analysis-ik/releases Bo Master Update is timely, 5.5.1 already have.
3) Pinyin Analyzer
GitHub Address: Https://github.com/medcl/elasticsearch-analysis-pinyin
IK and pinyin the same author, the founder of the elastic Chinese community.
4) Elasticsearch-analysis-lc-pinyin Analyzer
This plug-in is also very good, but no pinyin momentum big. Support full spell, first letter, Chinese mixed search. After the pinyin full-text search prepares the test effect, the current parser is still using IK and pinyin. es cluster
ES cluster configuration, the authoritative tutorial is very rough, it took several days to return to the test, and finally found that the configuration file parameters are not thoroughly understand.
Minimum Master Nodes
The setting of the minimum number of primary nodes is very important for the stability of the cluster. This setting is helpful for preventing brain fissures, i.e. there are two master in a cluster.
This configuration tells Elasticsearch that unless there is enough master candidate nodes available, the master is not elected, and only a sufficient master candidate node is available for election.
This setting should always be configured as the number of legal nodes with primary node eligibility, number of legal nodes: (Number of nodes/2 of primary node eligibility) +1. For example:
1, if you have 10 rules of the number of nodes, the legal number is 6.
2, if you have 3 candidate master, and 100 data nodes, the legal number is 2, you just calculate those who have the primary node qualification of the number of nodes can be.
3, if you have 2 rules of the number of nodes, the number of legal nodes should be 2, but this means that if a node dog, your entire cluster can not be used. Setting it to 1 will guarantee the functionality of the cluster, but it will not prevent the brain from splitting. Based on this situation, the best solution is to have at least 3 nodes.
Small clusters or local tests can be used without distinguishing between master Node,data node,client node. But the production environment to ensure maximum scalability, the official recommended different types of nodes to differentiate, the default elasticsearch is both master node and data node. For the knowledge of the node, refer to the reproduced "Elasticsearch node type".
I am currently using the cluster configuration: A client node, 3 Master/data hybrid nodes. Using Restclient can save a client node. Create an index, type example
1. Creating an index and Configuration analyzer
{"
settings": {"
index": {
"number_of_shards": 3,
"Number_of_replicas": 1,
"Analysis": {
" Analyzer ": {"
Ik_analyzer ": {"
type ":" Custom ",
" Tokenizer ":" Ik_smart "
},
" Pinyin_analyzer ": {
"Tokenizer": "My_pinyin"
}
},
"Tokenizer": {
"My_pinyin": {
"type": "Pinyin",
"keep_original": True
}
}
}}}
2. Create type and set mapping
{"Producttour": {"Properties": {"CompanyID": {"type": "Integer"}, "ProductCode": {"type": "Keyword"}, "ProductType": {"type
":" Text "," Analyzer ":" Ik_analyzer "," fields ": {" Pinyin ": {
"Type": "Text", "Analyzer": "Pinyin_analyzer"}}
}, "GType": {"type": "Keyword"}, "Linetype": {
"Type": "Keyword"}, "Productstate": {"type": "Boolean"}, "Auditstate": {"type": "Integer"}, "Productmaintitle": {"type": "T
Ext "," Analyzer ":" Ik_analyzer "," fields ": {" Pinyin ": {
"Type": "Text", "Analyzer": "Pinyin_analyzer"}}, "PR
Oductsubtitle ": {" type ":" Text "," Analyzer ":" Ik_analyzer "," fields ": {
"Pinyin": {"type": "Text", "Analyzer": "Pinyin_analyzer"
}}}, "Supplyproductname": {"type": "Keyword"
}, "Productmainpic": {"type": "Keyword"}, "Productpic": {
"Type": "Keyword"}, "DPT": {"type": "Keyword"},
"Arr": {"type": "Text", "Analyzer": "Ik_analyzer", "fields": {
"Pinyin": {"type": "Text", "Analyzer": "Pinyin_analyzer"
} }}, "Productfeatures": {"type": "Text", "Analyzer": "Ik_analyzer"
, "Fields": {"Pinyin": {"type": "Text",
"Analyzer": "Pinyin_analyzer"}}, "Tripday": { "Type": "Integer"}, "Tripnight": {"type": "Integer"}, " Advancedays ": {" type ":" Integer "}," Auditresult ": {" type ":" Keyword "}," Createtime ": {" type ":" Date "}}}3. Full-Text Search
{"From
": 0,
"size": ten, //Paged Query
"query": {
"bool": {"
must": [
{
"Multi_match": { Full-Text Search
"query": "1st", //Keywords
"fields": [ //Full-Text search field
"ProductType",
"Productmaintitle",
"Productsubtitle",
"arr",
"Productfeatures"
]
}
}
],
"filter": [ Filter condition
{
"term": {
"ProductType": "Themt"}}
]
}}
If the keyword is mixed with alphabetic characters, the full-text search field is replaced by:
"Fields": [
//Full-Text search field "Producttype.pinyin",
"Productmaintitle.pinyin",
"Productsubtitle.pinyin"
, "Arr.pinyin",
"Productfeatures.pinyin"
]
Pits encountered in use:
Mapping set to strict, dynamic introduction of [Doc] is not available; Use the term type, that is, the exact query, the character type uses keyword. The text cannot be used; If the keyword is a Chinese character, use the IK word breaker; If the keyword is mixed with pinyin or pinyin character, use pinyin word breaker;