_score(分数)字段是衡量文档与搜索条件匹配程度的一个指标。分数越高,文档越相关,分数越低,文档越不相关。并不总是需要生成分数,需不需要Elasticsearch会自动判断,以避免计算无用的分数。

布尔查询还支持filter子句,用于设置过滤条件。过滤条件不影响文档的相关性分数。

下面的例子,使用布尔查询,返回余额在20000到30000之间的所有帐户。

API

GET /bank/_search
{
"query": {
"bool": {
"must": { "match_all": {} },
"filter": {
"range": {
"balance": {
"gte": 20000,
"lte": 30000
}
}
}
}
}
}

CURL

curl -X GET "localhost:9200/bank/_search" -H 'Content-Type: application/json' -d'
{
"query": {
"bool": {
"must": { "match_all": {} },
"filter": {
"range": {
"balance": {
"gte": 20000,
"lte": 30000
}
}
}
}
}
}
'

上面的布尔查询中,包含一个match_all查询(查询部分)和一个range查询(筛选部分)。过滤条件中的range查询不影响文档的相关性分数计算。

除了match_allmatchboolrange查询,还有其他许多查询类型,工作原理大同小异,可参考相关资料。

Elasticsearch 过滤的更多相关文章

  1. elasticsearch系列四:搜索详解(搜索API、Query DSL)

    一.搜索API 1. 搜索API 端点地址 从索引tweet里面搜索字段user为kimchy的记录 GET /twitter/_search?q=user:kimchy 从索引tweet,user里 ...

  2. elasticsearch最全详细使用教程:搜索详解

    一.搜索API 1. 搜索API 端点地址从索引tweet里面搜索字段user为kimchy的记录 GET /twitter/_search?q=user:kimchy从索引tweet,user里面搜 ...

  3. Elasticsearch Query DSL(查询语言)

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  4. Elasticsearch 搜索API

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  5. Elasticsearch 搜索数据

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  6. Elasticsearch 批处理

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  7. Elasticsearch 删除文档

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  8. Elasticsearch 更新文档

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

  9. Elasticsearch 修改数据

    章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...

随机推荐

  1. Javascript调用本地数据库

    window.location.href = urls; // 本窗口打开下载 window.open(urls, '_blank'); // 新开窗口下载 (1)new ActiveXObject( ...

  2. php循环语句for while do while的用法

    循环结构 一.while循环 while(表达式){ 循环体;//反复执行,直到表达式为假} <?php$num = 1; while ($num <= 10){    print &qu ...

  3. question1 赋值运算操作符

    注意的问题书上讲的很详细了 下面是代码实现,但是VS有一个问题,strcpy安全性较低,虽然可以通脱编译,但是运行会报错,提示用strcpy_s()替代,但是,这里用strcpy()替代也不行, // ...

  4. 多元线性回归算法python实现(非常经典)

    对于多元线性回归算法,它对于数据集具有较好的可解释性,我们可以对比不过特征参数的输出系数的大小来判断它对数据的影响权重,进而对其中隐含的参数进行扩展和收集,提高整体训练数据的准确性.整体实现代码如下所 ...

  5. Springboot配置文件内容加密

      使用的是jasypt-spring-boot-starter,具体介绍可以参考 https://gitee.com/yangziyi2017/Jasypt-Spring-Boot   引入依赖 & ...

  6. NO17 第二关考试: 返回上次目录和ls -lrt倒序看文件--删除7天前的日志--查看日志更新--记录行号

    第二题:不用cd /ildboy命令如何回到上一次的目录: 假如当前目录是: [root@localhost oldboy]# pwd/oldboy现在因为需要进入到了/tmp目录下进行操作,执行的命 ...

  7. thinkphp的增删改查命令 - (mysql-thinkphp) (4)

    方法1,在namespace下面加2行 use think\Controller; use think\Db; 1.查询所有结果 $res = Db::query("select * fro ...

  8. 2.13 阶段实战 使用layui重构选课系统

    一.说在前面   昨天  学习表单校验插件validate,并使用ajax 自定义校验规则   今天 使用layui重构选课系统 二.题目要求 1.项目需求: 本项目所开发的学生选课系统完成学校对学生 ...

  9. SChema 多个属性的设置学习

    <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http:/ ...

  10. springCloud 之 Eureka服务治理

    服务治理是微服务架构中最核心和基础的模块 首先我们创建一个springCloud eureka service的springboot 工程,该工程提供一个服务中心,用来注册服务,第二个工程是clien ...