利用kibana插件对Elasticsearch进行bool查询
#bool查询
#老版本的filtered查询已经被bool代替
#用 bool包括 must should must_not filter来完成 ,格式如下:
#bool:{
# "filter":[],
# "must":[],
# "should":[],
# "must_not"[],
#}
#must 数组内的所有查询都必须满足
#should 数组内只需要满足一个
#must_not 一个都不能满足
#建立测试数据
POST lagou/testdb/_bulk
{"index":{"_id":}}
{"salary":,"title":"python"}
{"index":{"_id":}}
{"salary":,"title":"Scrapy"}
{"index":{"_id":}}
{"salary":,"title":"Django"}
{"index":{"_id":}}
{"salary":,"title":"Elasticsearch"}
#简单过滤查询
#最简单的fiter查询
#select * from testdb where salary=20
#filter 薪资为20的工作
GET lagou/testdb/_search
{
"query":{
"bool": {
"must":{
"match_all":{}
},
"filter": {
"terms": {
"salary": [,]
}
}
}
}
}
#filter里面也能写多值查询
#select * from testdb where title="python"
GET lagou/testdb/_search
{
"query":{
"bool": {
"must":{
"match_all":{}
},
"filter": {
"term": {
"title": "Python"
}
}
}
}
}
#数据在入库的时候就都已经进行大小写处理了,所以现在用term查询的时候是找不到需要的内容的,但是用match的时候就可以了
#查看分析器的解析结果
GET _analyze
{
"analyzer": "ik_max_word",
"text":"python网络"
}
#bool过滤查询,可以组合过滤查询
# select * from testdb where (salary=20 OR title=Python) AND (salary != 30)
# 查询薪资等于20k或者工作为python的工作,排除价格为30k的
GET lagou/testdb/_search
{
"query":{
"bool": {
"should":[
{"term": {"salary": }},
{"term": {"title": "python"}}
],
"must_not": [
{"term":{"salary":}},
{"term":{"salary":}}
]
}
}
} x
#嵌套查询
#select * from testdb where title="python" or ( title="django" AND salary=30)
GET lagou/testdb/_search
{
"query":{
"bool": {
"should":[
{"term": {"title": "python"}},
{"bool": {
"must": [
{"term": {"title": "django"}},
{"term": {"salary": }}
]
}}
]
}
}
}
#过滤空和非空
#建立测试数
#select tags from testdb2 where tags is not NULL
GET lagou/testdb2/_bulk
{"index":{"_id":""}}
{"tags":["salary"]}
{"index":{"_id":""}}
{"tags":["salary","python"]}
{"index":{"_id":""}}
{"other_fields":["some data"]}
{"index":{"_id":""}}
{"tags":null}
{"index":{"_id":""}}
{"tags":["salary",null]}
#处理null空值的方法
#select tags from testdb2 where tags is not NULL
GET lagou/testdb2/_search
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "tags"
}
}
}
}
}
利用kibana插件对Elasticsearch进行bool查询的更多相关文章
- 利用kibana插件对Elasticsearch查询
利用kibana插件对Elasticsearch查询 Elasticsearch是功能非常强大的搜索引擎,使用它的目的就是为了快速的查询到需要的数据. 查询分类: 基本查询:使用Elasticsear ...
- 利用kibana插件对Elasticsearch进行映射
映射(mapping) 映射是创建索引的时候,可以预先定义字段的类型以及相关属性 Elasticsearch会根据JSON源数据的基础类型去猜测你想要的字段映射.将输入的数据变成可搜索的索引项.Map ...
- 利用kibana插件对Elasticsearch进行批量操作
#############批量获取################# #获取所有数据 GET _mget { "docs": [ {"_index":" ...
- 利用kibana插件对Elasticsearch进行文档和索引的CRUD操作
#添加索引PUT lagou { "settings": { "index": { , } } }#查看 索引设置 GET lagou/_settings GE ...
- 使用kibana来进行ElasticSearch的信息查询检索
大家经常会听到使用ELK搭建日志管理平台.完成日志聚合检索的功能,那么这个平台到底是个什么概念,怎么搭建,怎么使用呢? ELK包括ElasticSearch(数据存储.快速查询).logstash(日 ...
- 利用Logstash插件进行Elasticsearch与Mysql的数据
Logstash与Elasticsearch的安装就不多说了,我之前有两篇文章写的比较详细了ElasticSearch + Logstash + Kibana 搭建笔记 和 Filebeat+Logs ...
- kibana和ElasticSearch的信息查询检索
使用kibana来进行ElasticSearch的信息查询检索 大家经常会听到使用ELK搭建日志管理平台.完成日志聚合检索的功能,那么这个平台到底是个什么概念,怎么搭建,怎么使用呢? ELK包括Ela ...
- 利用kibana学习 elasticsearch restful api (DSL)
利用kibana学习 elasticsearch restful api (DSL) 1.了解elasticsearch基本概念Index: databaseType: tableDocument: ...
- Elasticsearch索引的操作,利用kibana 创建/删除一个es的索引及mapping映射
索引的创建及删除 1. 通过索引一篇文档创建了一个新的索引 .这个索引采用的是默认的配置,新的字段通过动态映射的方式被添加到类型映射. 利用Kibana提供的DevTools来执行命令,要创建一个索引 ...
随机推荐
- Linux工具安装和常用配置
1 常用开发工具安装 1 安装Mysql ①基本安装 wget http://repo.mysql.com/mysql57-community-release-el7-10.noarch.rpm: s ...
- 使用Docker安装Nginx
启动命令 docker run -d -p : --name nginx -v $PWD/nginx.conf:/etc/nginx/nginx.conf -v $PWD/conf.d/:/etc/n ...
- [Reinforcement Learning] 动态规划(Planning)
动态规划 动态规划(Dynamic Programming,简称DP)是一种通过把原问题分解为相对简单的子问题的方式求解复杂问题的方法. 动态规划常常适用于具有如下性质的问题: 具有最优子结构(Opt ...
- mysql的The user specified as a definer (”@’%') does not exist 的解决办法
两种可能: 1.用户权限不够 赋给用户所有权限试试 mysql> grant all privileges on *.* to root@"%" identified by ...
- MVC加载分布页的三种方式
第一种: @Html.Partial("_分部页") 第二种: @{ Html.RenderPartial("分部页" ...
- idea2018注册
1.在网上随便找一个注册码,lanyu的即可,注册时会被提示此注册码已被取消. 2.修改hosts文件,目录:C:\Windows\System32\drivers\etc\hosts,在文件中添加 ...
- LeetCode第二十题-有效的括号
Valid Parentheses 问题简介: 给定一个只包含字符 ‘(’ , ‘)’ , ‘{’ , ‘}’ , ‘[’ , ‘]’ 的字符串,确定输入字符串是否有效 有效的条件: 必须使用相同类型 ...
- mitx一大堆统计学知识
从几乎0一路讲到马克洛夫 mit的密度太高了 下次必须花3天时间准备
- Iterator接口(迭代器)
目录 前言 原理 方法 异常 Iterator接口(迭代器) 前言 一般遍历数组都是采用for循环或者增强for,这两个方法也可以用在集合框架,但是还有一种方法是采用迭代器遍历集合框架,它是一个对象, ...
- expect 批量自动部署ssh 免密登陆 之 二
#!/usr/bin/expect -f ########################################## hutu #Push the id.pas.pub public key ...