Elasticsearch 过滤
_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_all、match、bool和range查询,还有其他许多查询类型,工作原理大同小异,可参考相关资料。
Elasticsearch 过滤的更多相关文章
- elasticsearch系列四:搜索详解(搜索API、Query DSL)
一.搜索API 1. 搜索API 端点地址 从索引tweet里面搜索字段user为kimchy的记录 GET /twitter/_search?q=user:kimchy 从索引tweet,user里 ...
- elasticsearch最全详细使用教程:搜索详解
一.搜索API 1. 搜索API 端点地址从索引tweet里面搜索字段user为kimchy的记录 GET /twitter/_search?q=user:kimchy从索引tweet,user里面搜 ...
- Elasticsearch Query DSL(查询语言)
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
- Elasticsearch 搜索API
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
- Elasticsearch 搜索数据
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
- Elasticsearch 批处理
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
- Elasticsearch 删除文档
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
- Elasticsearch 更新文档
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
- Elasticsearch 修改数据
章节 Elasticsearch 基本概念 Elasticsearch 安装 Elasticsearch 使用集群 Elasticsearch 健康检查 Elasticsearch 列出索引 Elas ...
随机推荐
- 大部分政府网站U-mail存在直接拿shell漏洞
大部分网站政府网站U-mail存在直接拿shell漏洞加入webmail/userapply.php?execadd=333&DomainID=111直接爆出物理地址 然后将 aa' unio ...
- 十五、web中处理乱码问题总结
一.jsp变成之道---中文乱码 jsp在转换为Servlet的过程经过三次编码转化: 转自 http://www.cnblogs.com/chenssy/p/4235191.html 二.java ...
- There is no Action mapped for action name hello.
- 嵊州普及Day3T4
利内罗女士准备来到意大利进行修行.意大利由 n 个城市和 m 条道路构成,道路是双向的.到达第 i 个城市时,她可以取得该城市的全部信仰,并获得 ai 点能力提升,但因为在一个城市可以取得的信仰有 ...
- CRM:异步加载下拉列表,三个列表出现同样的下拉框
异步加载下拉列表,三个列表出现同样的下拉框,原因如下: Spring默认单例,如果Action是单例,那么上一次查询的结果就可能被下一次的查询所调用.所以必须配置action为多例, 如果采用单例模式 ...
- Service IP 原理【转】
Service Cluster IP 是一个虚拟 IP,是由 Kubernetes 节点上的 iptables 规则管理的. 可以通过 iptables-save 命令打印出当前节点的 iptable ...
- day02-Python运维开发基础
1. Number 数据类型 2. 容器数据类型-字符串 """ 语法: "字符串" % (值1,值2 ... ) 占位符: %d 整型占位符 %f ...
- Kubernetes——容器集群
kuberneteskubernetes(k8s)是google的容器集群管理系统,在docker的基础之上,为容器化的应用提供部署运行.资源调度.服务发现和动态伸缩等一系列完整的功能,提高了大规模容 ...
- oracle练习-day04
.什么是PL.PL.普通变量和常量使用) :) :.引用型变量 .记录型变量.条件分支语法:if 条件 .根据输入的年龄判断小于输出未成年人,成年人,以上老年人): .loop循环语法:.输出到的数 ...
- bzoj 1138: [POI2009]Baj 最短回文路
额,,貌似网上的题解都说超时之类的. 然而我这个辣鸡在做的时候不知道在想什么,连超时的都不会. 超时的大概是这样的,f[x][y]表示x到y的最短回文路,然后更新的话就是 f[x][y]更新到 f[a ...