elasticsearch的rest搜索--- 查询
目录: 一、针对这次装B 的解释
四、 查询
四、 查询
1. 查询的官网的文档

- took —— Elasticsearch执行这个搜索的耗时,以毫秒为单位- timed_out —— 指明这个搜索是否超时
- _shards —— 指出多少个分片被搜索了,同时也指出了成功/失败的被搜索的shards的数量
- hits —— 搜索结果
- hits.total —— 能够匹配我们查询标准的文档的总数目
- hits.hits —— 真正的搜索结果数据(默认只显示前10个文档)- _score和max_score —— 现在先忽略这些字段
"query":{
"match":{
"UserName":"BWH-PC"
}
}
{
"query": {
"match": {
"text": "quick fox"
}
}
}
相当于
{
"query": {
"bool": {
"should": [
{
"term": {
"text": "quick"
}
},
{
"term": {
"text": "fox"
}
}
]
}
}
}
{
"query": {
"multi_match": {
"query": "bbc0641345dd8224ce81bbc79218a16f",
"operator": "or",
"fields": [
"*.machine"
]
}
}
}
{
"bool": {
"must": {
"match": {
"title": "how to make millions"
}
},
"must_not": {
"match": {
"tag": "spam"
}
},
"should": [
{
"match": {
"tag": "starred"
}
},
{
"range": {
"date": {
"gte": "2014-01-01"
}
}
}
]
}
}
"term": {
"CapabilityDescriptions": "aa"
}
{
"query": {
"bool": {
"should": [
{
"constant_score": {
"query": {
"match": {
"description": "wifi"
}
}
}
},
{
"constant_score": {
"query": {
"match": {
"description": "garden"
}
}
}
},
{
"constant_score": {
"boost": {
"query": {
"match": {
"description": "pool"
}
}
}
}
}
]
}
}
}
missing相当于is null【没查到的是null】
{
"query": {
"filtered": {
"query": {
"match": {
"email": "business opportunity"
}
},
"filter": {
"term": {
"folder": "inbox"
}
}
}
}
}
{
"query": {
"filtered": {
"filter": {
"bool": {
"must": {
"term": {
"folder": "inbox"
}
},
"must_not": {
"query": {
"match": {
"email": "urgent business proposal"
}
}
}
}
}
}
}
}
"range": {
"price": {
"gt": 20,
"lt": 40
}
}
{
"query": {
"filtered": {
"filter": {
"range": {
"price": {
"gte": 20,
"lt": 40
}
}
}
}
}
}
{
"range": {
"timestamp": {
"gt": "2014-01-0100: 00: 00",
"lt": "2014-01-0700: 00: 00"
}
}
}
{
"range": {
"timestamp": {
"gt": "now-1h"
}
}
}
后置过滤--post_filter元素是一个顶层元素,只会对搜索结果进行过滤。警告:性能考量
只有当你需要对搜索结果和聚合使用不同的过滤方式时才考虑使用post_filter。有时一些用户会直接在常规搜索中使用post_filter。
不要这样做!post_filter会在查询之后才会被执行,因此会失去过滤在性能上帮助(比如缓存)。
post_filter应该只和聚合一起使用,并且仅当你使用了不同的过滤条件时。
{
"query": {
"query_string": {
"query": "*"
}
},
"post_filter": {
"bool": {
"should": {
"query": {
"bool": {
"should": [
{
"match": {
"machine": "bbc0641345dd8224ce81bbc79218a16f"
}
},
{
"match": {
"machine": "bbc0641345dd8224ce81bbc79218a16f"
}
}
]
}
}
}
}
}
}
当然,在里面的每一个should中,可以去做很多变形,但是should多个子类时,必须用[]
{
"query": {
"query_string": {
"query": "*"
}
},
"post_filter": {
"bool": {
"should": [
{
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "bbc0641345dd8224ce81bbc79218a16f",
"operator": "or",
"fields": [
"*.machine",
""
]
}
},
{
"multi_match": {
"query": "10.10.185.99",
"operator": "or",
"fields": [
"*.IPAddress",
""
]
}
}
]
}
}
},
{
"query": {
"bool": {
"must": [
{
"match": {
"machine": "bbc0641345dd8224ce81bbc79218a16f"
}
},
{
"match": {
"IPAddress": "10.10.11.11"
}
}
]
}
}
}
]
}
}
}


{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "*"
}
},
"filter": {
"bool": {
"should": {
"query": {
"bool": {
"should": [
{
"multi_match": {
"query": "a2",
"operator": "or",
"fields": [
"*.last"
]
}
},
{
"match": {
"last": "a2"
}
}
]
}
}
}
}
}
}
}
}

elasticsearch的rest搜索--- 查询的更多相关文章
- ElasticSearch High Level REST API【2】搜索查询
如下为一段带有分页的简单搜索查询示例 在search搜索中大部分的搜索条件添加都可通过设置SearchSourceBuilder来实现,然后将SearchSourceBuilder RestHighL ...
- ElasticSearch第四步-查询详解
ElasticSearch系列学习 ElasticSearch第一步-环境配置 ElasticSearch第二步-CRUD之Sense ElasticSearch第三步-中文分词 ElasticSea ...
- ElasticSearch中的简单查询
前言 最近修改项目,又看了下ElasticSearch中的搜索,所以简单整理一下其中的查询语句等.都是比较基础的.PS,好久没写博客了..大概就是因为懒吧.闲言少叙书归正传. 查询示例 http:// ...
- ElasticSearch(8)-分布式搜索
分布式搜索的执行方式 在继续之前,我们将绕道讲一下搜索是如何在分布式环境中执行的. 它比我们之前讲的基础的增删改查(create-read-update-delete ,CRUD)请求要复杂一些. 注 ...
- ElasticSearch(6)-结构化查询
引用:ElasticSearch权威指南 一.请求体查询 请求体查询 简单查询语句(lite)是一种有效的命令行_adhoc_查询.但是,如果你想要善用搜索,你必须使用请求体查询(request bo ...
- ElasticSearch改造研报查询实践
背景: 1,系统简介:通过人工解读研报然后获取并录入研报分类及摘要等信息,系统通过摘要等信息来获得该研报的URI 2,现有实现:老系统使用MSSQL存储摘要等信息,并将不同的关键字分解为不同字段来提供 ...
- elasticsearch基本概念与查询语法
序言 后面有大量类似于mysql的sum, group by查询 elk === elk总体架构 https://www.elastic.co/cn/products Beat 基于go语言写的轻量型 ...
- Graylog日志管理系统---搜索查询方法使用简介
Elasticsearch 是一个基于 Lucene 构建的开源.分布式.提供 RESTful 接口的全文搜索引擎 一.Search页面的各位置功能介绍: 1.日志搜索的时间范围 为了使用方便,预设有 ...
- 第三百六十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的基本查询
第三百六十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的基本查询 1.elasticsearch(搜索引擎)的查询 elasticsearch是功能 ...
随机推荐
- Windows Azure应用系列:微软的云部署VPN
本文介绍如何使用OpenVPN微软云计算server既定VPN维修. 过程,如下面: 1.新建Linux或者Ubuntu虚拟机.并设置port.(本文将建立Ubuntu作为演示) 2.利用PuTTY登 ...
- SRM 620 D2L3: RandomGraph, dp
称号:http://community.topcoder.com/stat? c=problem_statement&pm=13143&rd=15853 參考:http://apps. ...
- window下自己主动备份数据库成dmp格式的bat写法
复制以下的命令到一个txt文本文档,然后改动相应的參数为自己须要的參数,一切完毕之后,将文件保存为bat格式. 这样每次须要备份的时候仅仅须要双击一下这个bat文件.其它的都不用你了,你仅仅须要静静的 ...
- leetcode第一刷_Minimum Path Sum
能够用递归简洁的写出,可是会超时. dp嘛.这个问题须要从后往前算,最右下角的小规模是已知的,边界也非常明显,是最后一行和最后一列,行走方向的限制决定了这些位置的走法是唯一的,能够先算出来.然后不断的 ...
- web即时通讯2--基于Spring websocket达到web聊天室
如本文所用,Spring4和websocket要构建web聊天室,根据框架SpringMVC+Spring+Hibernate的Maven项目,后台使用spring websocket进行消息转发和聊 ...
- all about AIX MPIO
Multipath I/O (多路径) 在计算机存储技术里,多路径提供了容错和性能提高,在计算机系统里CPU有多条物理路径通道,块存储设备通过总线,控制器,交换设备以及桥接设备来连接. ...
- PKU A Simple Problem with Integers (段树更新间隔总和)
意甲冠军:一个典型的段树C,Q问题,有n的数量a[i] (1~n),C, a, b,c在[a,b]加c Q a b 求[a,b]的和. #include<cstdio> #include& ...
- js怎样推断一个对象{}是否为空对象,没有不论什么属性
js怎样推断一个对象{}是否为空对象,没有不论什么属性 前段时间用js写了一个相似"angularjs"用于数据绑定的东西,功能是比較简单了, 通常应该传进来的是一个ArrayLi ...
- python 性能- and-or 学习技能
C语言类似表情: bool ? a : b ,当表达式值为真的话,值为a.否则为b. 看一个样例: >>> a = "first" >>> b ...
- Java读书笔记三(字符串)
1.介绍 本篇博客将对JAVA中的字符串类的基本知识进行介绍.主要字符串类的一些经常用法等内容. 2.字符串对象的创建 1.有两种形式.可是在开发中常常习惯于String 变量名的形式来进行操作. & ...