elk安装包
ElasticSearch教程——Kibana简单操作ES
ElasticSearch教程——创建索引、类型、文档
1、 #查询所用索引信息
GET _search
{
"query": {
"match_all": {}
}
}
2、#创建索引
PUT /whclogtest
{
"settings": {
"number_of_shards" : 5,
"number_of_replicas" : 0
}
}
PUT /testadd
{
"settings": {
"number_of_shards" : 5,
"number_of_replicas" : 0
}
}
3、#查看索引信息
GET /whclogtest
4、#修改索引副本数
PUT /whclogtest/_settings
{
"number_of_replicas":2
}
5、#删除索引
DELETE /testadd
#或者
DELETE /testadd*
6、#查询索引所用文档
GET /whclogtest/_search
{
"query": {
"match_all": {}
}
}
7、只查询显示type和host… (GET 或POST)
GET /whclogtest/_search
{
"query": {
"match_all": {}
},
"_source": ["type","host","message"]
}
8、#返回message包含ccplogin的document
POST /whclogtest/_search
{
"query": { "match": { "message": "ccplogin" } }
}
9、#返回message包ccplogin和1k的document
POST /whclogtest/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"message": "ccplogin"
}
},
{
"match": {
"message": "1k"
}
}
]
}
}
}
10、#返回message包8k或ccplogin的document
POST /whclogtest/_search
{
"query": {
"bool": {
"should": [
{"match": {
"message": "whc"}},
{"match": {
"message": "ccplogin"}}
]
}
}
}
Demo
POST /ecommerce/product
{
"name" : "脉动",
"desc" : "this is 脉动 你好",
"price" : 90,
"producer" : "脉动饮料",
"tags": [ "饮料", "脉动" ]
}
GET /ecommerce/product/_search
{
"query": {
"match_all": {}
}
}
GET /ecommerce/product/1
GET /ecommerce/product/_search
{
"query" : {
"match" : {
"desc": "哈哈脉"
}
}
}