elasticsearch(es)查询-URI search命令

基本命令

  • q指定查询语句
  • df 默认字段,不指定时,会对所有字段进行查询
  • sort排序 / from size 用于排序
  • Profile 可以显示查询是如何执行.

查询示例

GET /movies/_search?q=2012&df=title
{
  "profile":"true"
}

可以看看结果
在这里插入图片描述
这里我们看可以看到 返回了2条数据
在这里插入图片描述
这里我们可以看到
type为"TermQuery"
description为"title:2012"

# 对所有字段就行查询(性能不好)
GET /movies/_search?q=2012
{
  "profile": "true"
}
# 对指定字段进行查询(这里和采用df指定字段是一样的)
GET /movies/_search?q=title:2012
{
"profile": "true"
}
# AND查询的title包含 Beautiful  和 Mind 这2个单词的(这里前后顺序要求一致)
GET /movies/_search?q=title:"Beautiful Mind"
{
  "profile": "true"
}
# OR查询的title包含 Beautiful 或 Mind (这里是没有引号的)
GET /movies/_search?q=title:Beautiful Mind
{
  "profile": "true"
}
# 布尔查询用"()"包起来 title 必需包含 Beautiful  或 Mind
GET /movies/_search?q=title:(Beautiful Mind)
{
  "profile": "true"
}
# 包含 Beautiful 并且 包含 Mind
GET /movies/_search?q=title:(Beautiful AND Mind)
{
  "profile": "true"
}
# 包含 Beautiful 并且不包含 Mind
GET /movies/_search?q=title:(Beautiful NOT Mind)
{
  "profile": "true"
}
# 范围查询 year 大于等于1980
GET /movies/_search?q=year:>=1980
{
  "profile": "true"
}
# 通配符查询 title包含b
GET /movies/_search?q=title:b*
{
  "profile": "true"
}
# 模糊匹配查询
GET /movies/_search?q=title:beautifl~1
{
  "profile": "true"
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值