1, elasticsearch installation
Or install it using the docker previously installed.
sudo docker pull elasticsearch:2.4.6
sudo docker run --name elasticsearch01 -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -p 9200:9200 -p 9300:9300 -d elasticsearch:2.4.6
Browser Test:
Prove successful installation.
2, we have to pay attention to: the index, type of document, property
We chose idea of tools - test resful web service, add the appropriate data to the ES.
Put request must be transmitted, Host system is the ip address: 9200, path is / megacorp / employee / 1, json text data in the band to be transmitted, after clicking operation: in the response:
See the type of index, id, version and other information. We add operation according to just two: / megacorp / employee / 2, / megacorp / employee / 3
Next we get the document:
In response to the information we / megacorp / employee / 1 storage.
Head can send a request, in response to this data 200 illustrates has:
Send delete can delete a data:
Updates, modify the data before you can use the Put request.
You can also enter _search query all records:
But also according to criteria query:
Or when we queried bring json formatted data:
{
“query”:{
"match":{
"first_name":"jack"
}
}
}
Then test it, to send a Post request.
也可以设置一些复杂的查询规则:
也可以进行全文检索:
只要我们的字段包含检索的字段,就会被检索出来,并会有相关性评分。
如果想完全匹配,将match改成match_phrase即可。
更多的查询可以去看官方文档。