首页 > 其他 > 详细

elasticsearch基本Restful操作

时间:2018-02-28 17:09:27      阅读:280      评论:0      收藏:0      [点我收藏+]

1、添加数据
curl -H "Content-Type: application/json" -XPUT ‘http://localhost:9200/megacorp/employee/3‘ -d‘
{
"first_name" : "Jane",
"last_name" : "Smith",
"age" : 32,
"about" : "I like to collect rock albums",
"interests": [ "music" ]
}‘;

2、删除数据
curl -XDELETE ‘http://localhost:9200/megacorp/employee/1‘

3、查看记录
curl -XGET ‘http://localhost:9200/megacorp/employee/1‘

4、查看所有记录
curl -XGET ‘http://localhost:9200/megacorp/employee/_search‘

5、简单条件查询
curl -XGET ‘http://localhost:9200/megacorp/employee/_search?q=last_name:Smith‘

6、match 查询法
curl -H "Content-Type: application/json" -XGET ‘http://localhost:9200/megacorp/employee/_search‘ -d‘
{
"query" : {
"match" : {
"about" : "rock climbing"
}
}
}‘

7、短语搜索(匹配若干个单词或者短语)
curl -H "Content-Type: application/json" -XGET ‘http://localhost:9200/megacorp/employee/_search‘ -d‘
{
"query" : {
"match_phrase": {
"about": "rock climbing"
}
}
}‘


8、结构化搜索的限定条件 filter(过滤器)
curl -XGET ‘http://localhost:9200/megacorp/employee/_search‘ -d‘
{
"query" : {
"filtered" : {
"filter" : {
"range" : {
"age" : { "gt" : 30 } <1>
}
},
"query" : {
"match" : {
"last_name" : "Smith" <2>
}
}
}
}
}

elasticsearch基本Restful操作

原文:https://www.cnblogs.com/runnerjack/p/8484497.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!