ES elasticsearch

新增

PUT /megacorp/employee/2{ "first_name" : "Jane", "last_name" : "Smith", "age" : 32, "about" : "I like to collect rock albums", "interests": [ "music" ]}PUT /megacorp/employee/3{ "first_name" : "Douglas", "last_name" : "Fir", "age" : 35, "about": "I like to build cabinets", "interests": [ "forestry" ]}
PUT / website / blog / 123 / _create 创建指定id的数据
{ ... }

查询


GET / megacorp / employee / 1 id查询 GET / megacorp / employee / _search 查询所有
GET / megacorp / employee / _search ? q = last_name : Smith 查询last_name = Smith

GET / megacorp / employee / _search 查询last_name = Smith
{ "query" : { "match" : { match 模糊搜索、match_phrase 全匹配 "last_name" : "Smith" } }}
GET / megacorp / employee / _search 过滤查询
{ "query" : { "filtered" : { "filter" : { "range" : { "age" : { "gt" : 30 } } }, "query" : { "match" : { "last_name" : "smith" } } } }} GET / _mget 组查询 { "docs" : [ { "_index" : "website" , "_type" : "blog" , "_id" : 2 }, { "_index" : "website" , "_type" : "pageviews" , "_id" : 1 , "_source" : "views" } ] }  

GET / website / blog / _mget 组查询 { "ids" : [ "2" , "1" ] }





返回结果{ "_index" : "megacorp", "_type" : "employee", "_id" : "1", "_version" : 1, "found" : true, "_source" : { "first_name" : "John", "last_name" : "Smith", "age" : 25, "about" : "I love to go rock climbing", "interests": [ "sports", "music" ] }}


GET / _search   全部查询
/_search
Search all types in all indices
/gb/_search
Search all types in the gb index
/gb,us/_search
Search all types in the gb and us indices
/g*,u*/_search
Search all types in any indices beginning with g or beginning with u
/gb/user/_search
Search type user in the gb index
/gb,us/user,tweet/_search
Search types user and tweet in the gb and us indices
/_all/user,tweet/_search
Search types user and tweet in all indices


返回结果:
{ "hits" : { "total" : 14 , "hits" : [ { "_index" : "us" , "_type" : "tweet" , "_id" : "7" , "_score" : 1 , "_source" : { "date" : "2014-09-17" , "name" : "John Smith" , "tweet" : "The Query DSL is really powerful and flexible" , "user_id" : 2 } }, ... 9 RESULTS REMOVED ... ], "max_score" : 1 }, "took" : 4 , "_shards" : { "failed" : 0 , "successful" : 10 , "total" : 10 }, "timed_out" : false 
} 
GET / _search ? size = 5 查出五个 GET / _search ? size = 5 & from = 5 从第五个开始查出五个 GET / _search ? size = 5 & from = 10 从第十个开始查出五个


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值