# 带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"
}
Elasticsearch基于URI Search的API的简单案例
最新推荐文章于 2024-07-30 07:35:42 发布