Elasticsearch .net client NEST 空字符/null值查询
null值查询
当某个字段值为null时,其实在es里该条数据是没有这个字段的。查询时检测包含不包含该字段就行。
/// <summary>
/// null 值查询
/// 当数据为Null时字段不存在
/// </summary>
/// <param name="indexName"></param>
public void NullValueQuery(string indexName)
{
var result = _client.Search<TestModel5>(
s => s
.Index(indexName)//索引
.Type(typeof(TestModel5))//类型
//fd.Name必须存在 即:fd.Name!=null
.Query(q=>q.Bool(b=>b.Must(mt=>mt.Exists(ex=>ex.Field(fd=>fd.Name))))
)); }
空字符查询
当某个字段值为空字符时(""),字段是存在的。
/// <summary>
/// 空字符查询
/// </summary>
/// <param name="indexName"></param>
public void StringEmptyQuery(string indexName)
{
var result = _client.Search<TestModel5>(
s => s
.Index(indexName)//索引
.Type(typeof(TestModel5))//类型
//.Verbatim()如果不加该查询条件无效
.Query(q => q.Bool(b => b.Must(mt => mt.Term(ex => ex.Verbatim().Field(fd => fd.Name).Value(""))))
));
}
感谢群友的普及。
如果你也在用NEST 不妨一起来交流学习吧。^.^
Elasticsearch.Net、NEST 交流群:523061899
Elasticsearch .net client NEST 空字符/null值查询的更多相关文章
- Elasticsearch .Net Client NEST 多条件查询示例
Elasticsearch .Net Client NEST 多条件查询示例 /// <summary> /// 多条件搜索例子 /// </summary> public c ...
- Elasticsearch .net client NEST 5.x 使用总结
目录: Elasticsearch .net client NEST 5.x 使用总结 elasticsearch_.net_client_nest2.x_到_5.x常用方法属性差异 Elastics ...
- Elasticsearch .Net Client NEST使用说明 2.x
Elasticsearch .net client NEST使用说明 2.x Elasticsearch.Net与NEST是Elasticsearch为C#提供的一套客户端驱动,方便C#调用Elast ...
- Elasticsearch .net client NEST使用说明 2.x -更新版
Elasticsearch .net client NEST使用说明 目录: Elasticsearch .net client NEST 5.x 使用总结 elasticsearch_.net_cl ...
- (转)Elasticsearch .net client NEST使用说明 2.x
Elasticsearch.Net与NEST是Elasticsearch为C#提供的一套客户端驱动,方便C#调用Elasticsearch服务接口.Elasticsearch.Net是较基层的对Ela ...
- Mysql Not in有null值查询的问题
今天发现Mysql的not in使用的一个问题,大致是: select * from A where id not in (select fid from B). 发现查询结果无论如何都是0条记录.后 ...
- Elasticsearch .Net Client NEST 索引DataSet数据
NEST 索引DataSet数据,先序列化然后转成dynamic 类型进行索引: /// <summary> /// 索引dataset /// </summary> /// ...
- mysql null 值查询问题
我在开发公司内部的一个项目时遇到一个问题:select student_quality_id from STUDENT_QUALITY where mark_status=0 and batch_st ...
- SQL null值 查询null
select * from emp;
随机推荐
- Linux_磁盘分布_以及分区
运用 Xshell 工具链接到你的服务器 1. Fdisk -l 这是查看磁盘挂载列表情况 2. Fdisk /dev/vdc 这是分区这个磁盘 m 是查看信息 ...
- Python_tkinter(4)_上传文件
1.上传单个文件 import tkinter as tk from tkinter import filedialog def upload_file(): selectFile = tk.file ...
- Python的基本语法2
一.运算符 # 算术运算符, +, -, *, /, //, %, **, 注意//为整除 # 赋值运算符, =, +=, -=, *=, /=, //= ,%=, **= # 比较运算符, ==, ...
- JVM深入:JVM内存堆布局图解分析(转)
转载自:https://www.cnblogs.com/SaraMoring/p/5713732.html 原文:http://www.codeceo.com/article/jvm-memory-s ...
- ROS学习备忘
1. remap的解释 For example, you are given a node that says it subscribes to the "chatter" top ...
- ShellExecute 打开网页、目录、邮箱
#include <Windows.h> #include <tchar.h> int WINAPI _tWinMain(HINSTANCE hInstance, HINSTA ...
- python运算符和数据类型的可变性
一.运算符 计算机可以进行的运算有很多种,不只是加减乘除,它和我们人脑一样,也可以做很多运算. 种类:算术运算,比较运算,逻辑运算,赋值运算,成员运算,身份运算,位运算,今天我们先了解前四个. 算术运 ...
- django中static的坑
在django搭建网络平台的时候免不了要使用到static来保存静态文件, 在static文件夹里包含两个文件:css和js文件,如果使用不当就会出现很多问题 第一个坑:配置文件settings.py ...
- 求你显示pdf
123 <iframe src='http://km.shengaitcm.com/ADC/_layouts/15/WopiFrame.aspx?sourcedoc=%2FADC%2FDocLi ...
- day19 python之re模块正则练习
1.匹配标签 import re ret = re.search("<(?P<tag_name>\w+)>\w+</(?P=tag_name)>" ...