ELK中elasticsearch的用法

来源:互联网 发布:喜纳昌吉 知乎 编辑:程序博客网 时间:2024/06/05 23:51
1、查询gather-005中 NAME='Lihua'
curl -XGET 'localhost:9200/gather-005/_search?pretty' -H 'Content-Type:application/json' -d'
{
 "query":{
  "match":{
 "NAME":"Lihua"
   }
  }
}'

curl -XGET 'localhost:9200/gather-005/_search?pretty' -H 'Content-Type:application/json' -d'
{
 "size":10,
 "query":{
  "term":{
  "NAME.keyword":"Lihua"
   }
  }
}'


2、查询 gather-010中前两个
curl -XGET 'localhost:9200/gather-005/_search?pretty' -H 'Content-Type:application/json' -d'
{
  "size":2
}
3、查询gather-000中area_type为0的前1个
curl -XGET 'localhost:9200/gather-005/_search?pretty' -H 'Content-Type:application/json' -d'
{
  "size":1,
  "query":{
    "term":{
        "NAME.keyword":"Lihua"
        }
    }
}'  
4、创建一个index
curl -XPUT 'localhost:9200/customer?pretty&pretty'
5、查看所有的index
curl -XGET 'localhost:9200/_cat/indices?v&pretty'
6、创建一个document domain/{index}/{type}/id
curl -XPUT 'localhost:9200/customer/external/1?pretty&pretty' -d'
{
 "name":"Li hua"
}
7、删除customer索引
curl -XDELETE 'localhost:9200/customer?pretty'
8、
curl -XPOST 'localhost:9200/customer/external?pretty&pretty' -d'
{
"name": "Jane Doe"
}'
更新:
curl -XPOST 'localhost:9200/customer/external/1/_update?pretty&pretty' -d'
{
"doc": { "name": "Jane Doe" }
}'
命令的格式:
<REST Verb> /<Index>/<Type>/<ID>


curl -XGET 'localhost:9200/gather-005/_search?pretty' -H 'Content-Type:application/json' -d'
{
    "aggs":{
           "newtype":{
                  "terms":{
                     "field":"NAME.keyword",
                     "size":100
                        }
                     }
            }
}'


curl -XGET 'localhost:9200/gather-005/_search?pretty' -H 'Content-Type:application/json' -d'
{
 "size":10,
 "query":{
    "term":{"area_type.keyword":"1"}
     },
    "aggs":{
        "newtype":{
           "terms":{
                "field":"NAME.keyword",
                "size":100
                    }
                 }
              }
}'

原创粉丝点击