C:\curl-7.51.0-win64-mingw>curl -XPUT "http://localhost:9200/dept/employee/1" -d "{"""empname""":"""emp1"""}"
curl 'localhost:9200/-cat/health?v'
curl 'localhost:9200/-cat/nodes?v'
C:\curl-7.51.0-win64-mingw>curl -XPUT "localhost:9200/customer?external/1?pretty" -d "{"""name""":"""John Doe"""}"
C:\curl-7.51.0-win64-mingw>curl -XGET "localhost:9200/customer/external/1?pretty"
curl -XDELETE "localhost:9200/customer?pretty"
-------------------------------------------------
随机id
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/customer/external?pretty" -d "{"""name""":"""Jackie Doe"""}"
-------------------------------------------------
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/customer/external/1/_update?pretty" -d "{"""doc""":{"""name""":"""jane Doe"""}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/customer/external/1/_update?pretty" -d "{"""doc""":{"""name""":"""jane Doe""","""age""":20}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/customer/external/1/_update?pretty" -d "{"""script""":"""ctx._source.age+=5"""}"
C:\curl-7.51.0-win64-mingw>curl -XDElETE "localhost:9200/customer/external/2?pretty"
C:\curl-7.51.0-win64-mingw>curl -XDElETE "localhost:9200/customer/external/_query?pretty" -d "{"""query""":{"""match""":{"""name""":"""Jackie Doe"""}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/customer/external/_bulk?pretty" -d "{"""index""":{"""_id""":"""1"""}}{"""name""": """John Doe""" }
{"""index""":{"""_id""":"""2"""}}{"""name""": """Jane Doe""" }'
curl -XPOST "localhost:9200/customer/external/_bulk?pretty" -d "{"""update""":{"""_id""":"""1"""}}{"""doc""": { """name""": """John Doe becomes Jane Doe""" } }
{"""delete""":{"""_id""":"""2"""}}"
导入json数据
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/account/_bulk?pretty" --data-binary @accounts.json
--------------------------------------------------
curl "localhost:9200/bank/_search?q=*&pretty"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""match_all""":{}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""match_all""":{}},"""from""":10,"""size""":10}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""match_all""":{}},"""sort""":{"""balance""":{"""order""":"""desc
"""}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""match_all""":{}},"""_source""":["""account_number""","""balance
"""]}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""match""":{"""account_number""":20}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""match""":{"""address""":"""mill"""}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""match""":{"""address""":"""mill lane"""}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""bool""":{"""must""":[{"""match"""":{""""address""":"""mill"""}}
,{"""match""":{"""address""":"""lane"""}}]}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""bool""":{"""should""":[{"""match""":{"""address""":"""mil"""}},
{"""match""":{"""address""":"""lane"""}}]}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""bool""":{"""must_not""":[{"""match""":{"""address""":"""mil"""}
},{"""match""":{"""address""":"""lane"""}}]}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""bool""":{"""must""":[{"""match""":{"""age""":"""40"""}}],"""must_not""":[{"""match""":{"""state""":"""ID"""}}]}}}"
过滤器
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""query""":{"""filtered""":{"""query""":{"""match_all""":{}},"""filter""":{"""
range""":{""""balance""":{"""gte""":20000,"""lte""":30000}}}}}};
聚合
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""size""":0,"""aggs""":{"""group_by_state""":{"""terms""":{"""field""":"""stat
e"""}}}}"
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""size""":0,"""aggs""":{"""group_by_state""":{"""terms""":{"""field""":"""stat
e"""},"""aggs""":{"""average_balance""":{"""avg""":{"""field""":"""balance"""}}}
}}}"
出错
C:\curl-7.51.0-win64-mingw>curl -XPOST "localhost:9200/bank/_search?pretty" -d "{"""size""":0,"""aggs""":{"""group_by_state""":{"""terms""":{"""field""":"""stat
e"""},"""order""":{"""average_balance""":"""desc"""}},"""aggs""":{"""average_balance""":{"""avg""":{"""field""":"""balance"""}}}}}}"