Elasticsearch的null values
很多时候,我们需要面临null值的烦扰,查询es时传入null值是要查询出null的数据还是不查这个field呢,稍有不慎就会引发新的bug,这的确是个问题!
null_value 意味着无法索引或搜索空值。当字段设置为 null , [] ,和 [null] (这些null的表示形式都是等价的),它被视为该字段没有值。
null_value 意味着它将不会被表示为一个反向索引数据结构,它们根本不存在于反向索引中,故搜索也就无任何意义了。
难道就搜索没有办法了吗?
es为我们提供了missing查询,代表缺少字段或null值,但在6.x版本已经移除。取而代之的是exists查询,它的语义相当于SQL 中的 column is not null(有值)。它们都属于聚合操作。
显然,这个世界并不简单,数据常常缺少字段,或者包含显式的空或空数组。为了处理这些情况,es 给我们推荐了一些办法可以处理空值或缺少的值。
幸运的是,es 可以设置一个选项,用我们选择的占位符值替换显式的空值(当为字符串、数字、布尔值或日期字段指定映射时设置),当insert/update数据遇到空值时,将使用该值,这个显式的空值会对其进行索引,以便于搜索。
选择合适的空值时,请确保:
它与字段的类型匹配。在日期类型的字段中不能使用字符串空值
它不同于字段可能包含的正常值,以避免将实值与空值混淆
PUT my_index
{
"mappings": {
"_doc": {
"properties": {
"status_code": {
"type": "keyword",
"null_value": "NULL"
}
}
}
}
} PUT my_index/_doc/1
{
"status_code": null
} PUT my_index/_doc/2
{
"status_code": []
} GET my_index/_search
{
"query": {
"term": {
"status_code": "NULL"
}
}
}
Elasticsearch的null values的更多相关文章
- MySQL :: MySQL 8.0 Reference Manual :: B.6.4.3 Problems with NULL Values https://dev.mysql.com/doc/refman/8.0/en/problems-with-null.html
MySQL :: MySQL 8.0 Reference Manual :: B.6.4.3 Problems with NULL Values https://dev.mysql.com/doc/r ...
- Retain NULL values vs Keep NULLs in SSIS Dataflows - Which To Use? (转载)
There is some confusion as to what the various NULL settings all do in SSIS. In fact in one team whe ...
- You can add an index on a column that can have NULL values if you are using the MyISAM, InnoDB, or MEMORY storage engine.
w https://dev.mysql.com/doc/refman/5.7/en/create-index.html MySQL :: MySQL 5.7 Reference Manual :: B ...
- SQL NULL Values
NULL代表缺失的.未知的数据.表的列值默认是NULL.如果某个表的某个列不是NOT NULL的,那么当我们插入新纪录.更新已存在的记录时,可以不用为此列赋值,这意味着那个列保存为NULL值. NUL ...
- NOT IN clause and NULL values
https://stackoverflow.com/questions/129077/not-in-clause-and-null-values This issue came up when I g ...
- elasticsearch 中文API river
river-jdbc 安装 ./bin/plugin --install jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/pl ...
- TSQL 聚合函数忽略NULL值
max,min,sum,avg聚合函数会忽略null值,但不代表聚合函数不返回null值,如果表为空表,或聚合列都是null,则返回null.count 聚合函数忽略null值,如果聚合列都是null ...
- Warning: Null value is eliminated by an aggregate or other SET operation.
Null 值会被聚合函数忽略,默认情况下,Sql Server会给出Warning: Warning: Null value is eliminated by an aggregate or othe ...
- elasticsearch Java API汇总
http://blog.csdn.net/changong28/article/details/38445805#comments 3.1 集群的连接 3.1.1 作为Elasticsearch节点 ...
随机推荐
- PhpStorm注册使用方法
解压 sudo tar -zvxf PhpStorm-2019.3.tar.gz -C /usr/local 屏蔽hosts # Phpstorm 0.0.0.0 account.jetbrains. ...
- elasticsearch6设置默认分片数和副本数
elasticsearch6设置索引的默认分片数和副本数已经不是在elasticsearch.yml文件中了,而是使用了一个索引模板的东西 curl -XPUT 'http://10.27.12.16 ...
- 【LOJ#6485】LJJ 学二项式定理(单位根反演)
[LOJ#6485]LJJ 学二项式定理(单位根反演) 题面 LOJ 题解 显然对于\(a0,a1,a2,a3\)分开算答案. 这里以\(a0\)为例 \[\begin{aligned} Ans&am ...
- Linq 将两个查询结果合称为一个
var handsonitems = from a in db.DltQuestionHandson join c in db.DltBdChapter on new { a.ChapterCode ...
- kafka源码导入idea/eclipse
先进入源码工程:执行gradle idea或者gradle eclipse 之后再导入idea/eclipse
- C#中的System.Type和System.RuntimeType之间的区别
string str = string.Empty; Type strType = str.GetType(); Type strTypeType = strType.GetType(); strTy ...
- 记录一次OracleJDK开发的项目发部到Linux中使用OpenJDK启动后失败的错误的解决方案
一.现象 基于JAVA SpringBoot2.0.4的项目,发部后项目发部后,放到OpenJDK环境中运行时,提示下列错误: 2019-10-22 10:03:55 [main] WARN o.s ...
- ElasticSearch 查询索引
GET iis_qr_2019-07/_search #查询iis_qr_2019-07索引下的所有日志 GET iis_qr_2019-07/_search?_source=c-ip,time #只 ...
- Python文件属性模块Os.path
Python文件属性模块Os.path介绍 os.path模块主要用于文件属性获取和判断,在编程中会经常用到,需要熟练掌握.以下是该模块的几种常用方法. os.path官方文档:http://docs ...
- topshelf注册服务
1.需要从nutget上获取toshelf配置 2.代码 using Common.Logging; using Quartz; using Quartz.Impl; using System; us ...