Elasticsearch基于URI Search的API的简单案例


# 带profile的指定字段查询
GET /movies/_search?q=2012&df=title
{
  "profile": "true"
}

# 泛查询,对所有字段进行查询
GET /movies/_search?q=2012
{
  "profile": "true"
}

# 带profile的指定字段查询
GET /movies/_search?q=title:2012
{
  "profile": "true"
}

# 使用引号,Pharse查询,就是必须同时存在Beautiful和Mind,并且要保证顺序一致
GET /movies/_search?q=title:"Beautiful Mind"
{
  "profile": "true"
}

#term查询 title的Beautiful的term查询 以及所有字段Mind 的泛查询
GET /movies/_search?q=title: Beautiful Mind
{
  "profile": "true"
}

# 分组,boolean 查询 查询title中存在Beautiful 或者Mind 
GET /movies/_search?q=title:(Beautiful Mind)
{
  "profile": "true"
}

# 查询title包含Beautiful和Mind,并且顺序可以改变
GET /movies/_search?q=title:(Beautiful AND Mind)
{
  "profile": "true"
}

# 查询title中宝行Beautiful 但是不能包含Mind
GET /movies/_search?q=title:(Beautiful NOT Mind)
{
  "profile": "true"
}

# 分组,boolean 查询 查询title中存在Beautiful 或者Mind 
GET /movies/_search?q=title:(Beautiful OR Mind)
{
  "profile": "true"
}

# 分组 boolean 查询 查询title中必须包含Mind 
GET /movies/_search?q=title:(Beautiful11 %2BMind)
{
  "profile": "true"
}

# 范围查询
# 区间表示:[]闭空间,{}是开区间 
#查询年份大于2017的
GET /movies/_search/?q=year:>2017
{
  "profile": "true"
}

#查询年份大于等于2017
GET /movies/_search/?q=year:>=2017
{"profile": "true"}

#查询年份小于2017
GET /movies/_search?q=year:<2017
{"profile": "true"}

#查询年份小于等于2017
GET /movies/_search?q=year:<=2017
{"profile": "true"}

#查询年份大于等于2017并且小于等于2018
GET /movies/_search?q=year:[2017 TO 2018]
{"profile": "true"}

#查询年份大于2016并且小于等于2018
GET /movies/_search?q=year:{2016 TO 2018]
{
  "profile": "true"
}

#查询年份大于2016并且小于2018,即年份是2017年的
GET /movies/_search?q=year:{2016 TO 2018%7D
{
  "profile": "true"
}

#查询年份大于2016并且小于2018,即年份是2017年的
GET /movies/_search?q=title:Mind AND year:{2016 TO 2018%7D
{
  "profile": "true"
}

#通配符查询
#查询title中包含以b(不区分大小写)开头的单词
GET /movies/_search?q=title:b*
{"profile": "true"}

#模糊查询
GET /movies/_search?q=title:beautifl~1
{"profile": "true"}

#近似度匹配,但这个是有顺序的
GET /movies/_search?q=title:"Lord Rings"~2
{
  "profile": "true"
}












评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值