Elasticsearch 过滤器
序
本文主要记录es的查询过滤的使用。
使用过滤器
过滤器不影响评分,而评分计算让搜索变得复杂,而且需要CPU资源,因而尽量使用过滤器,而且过滤器容易被缓存,进一步提升查询的整体性能。
post_filter(先查询再过滤
)
{
"query": {
"match":{"title":"Catch-22"}
},
"post_filter":{
"term":{"year":}
}
}
filtered(先过滤再查询,速度快
)
{
"query": {
"filtered": {
"query": {
"match": {
"title": "Catch-22"
}
},
"filter": {
"term": {
"year":
}
}
}
}
}
这种方式在2.2版本被废弃调用,改用bool的方式
{
"query": {
"bool": {
"must": {
"match": {
"title": "Catch-22"
}
},
"filter": {
"term": {
"year":
}
}
}
}
}
过滤器种类
范围过滤器
{
"post_filter":{
"range":{
"year":{
"gte":,
"lte":
}
}
}
}
exists过滤器
{
"post_filter":{
"exists":{
"field":"year"
}
}
}
missing过滤器
过滤掉给定字段有值或缺失的文档
{
"post_filter":{
"missing":{
"field":"year",
"null_value":,
"existence":true
}
}
}
脚本过滤器
过滤掉发表在一个世纪以前的书
{
"post_filter":{
"script":{
"script":"now - doc[‘year‘].value > 100",
"params":{"now":}
}
}
}
类型过滤器
当查询运行在多个索引上时,有用
{
"post_filter":{
"type":{
"value":"book"
}
}
}
限定过滤器
限定每个分片返回的文档数
{
"post_filter":{
"limit":{
"value":
}
}
}
标识符过滤器
比如要指定标识符为1,2,3的文档
{
"post_filter":{
"ids":{
"type":["book"],
"values":[,,]
}
}
}
组合过滤器
{
"query": {
"bool": {
"must": {
"range": {
"year": {
"gte": ,
"lte":
}
}
},
"should": {
"term": {
"available": true
}
},
"boost":
}
}
}
Elasticsearch 过滤器的更多相关文章
- Elasticsearch过滤器——filter
Elasticsearch中的所有的查询都会触发相关度得分的计算.对于那些我们不需要相关度得分的场景下,Elasticsearch以过滤器的形式提供了另一种查询功能.过滤器在概念上类似于查询,但是它们 ...
- elasticsearch 过滤器的种类
elasticsearch之查询过滤 elasticsearch elastic-search xixicat 2月13日发布 推荐 1 推荐 收藏 2 收藏,289 浏览 序 本文主要记录es的查询 ...
- elasticsearch filters特性
使用filters优化查询 ElasticSearch支持多种不同类型的查询方式,这一点大家应该都已熟知.但是在选择哪个文档应该匹配成功,哪个文档应该呈现给用户这一需求上,查询并不是唯一的选择.Ela ...
- elasticsearch5之Elastalert 安装使用 配置邮件报警和微信报警
简介 Elastalert是用python2写的一个报警框架(目前支持python2.6和2.7,不支持3.x),github地址为 https://github.com/Yelp/elastaler ...
- Elastalert安装及使用
如果在windows 64平台报错:执行 pip install python-magic-bin==0.4.14修复https://stackoverflow.com/questions/18374 ...
- elastalert
http://blog.51cto.com/kexiaoke/1977481 什么是? ElastAlert是一个简单的框架,用于从弹性搜索中的数据中提取异常,尖峰或其他感兴趣的模式.在Yelp,我们 ...
- ELK日志报警插件ElastAlert并配置钉钉报警
文章转载自:https://www.cnblogs.com/uglyliu/p/13118386.html ELK日志报警插件ElastAlert 它通过将Elasticsearch与两种类型的组件( ...
- ELK基于ElastAlert实现日志的微信报警
文章转载自:https://mp.weixin.qq.com/s/W9b28CFBEmxBPz5bGd1-hw 教程pdf文件下载地址 https://files.cnblogs.com/files/ ...
- 【转】elasticsearch的查询器query与过滤器filter的区别
很多刚学elasticsearch的人对于查询方面很是苦恼,说实话es的查询语法真心不简单- 当然你如果入门之后,会发现elasticsearch的rest api设计是多么有意思. 说正题,ela ...
随机推荐
- cocos2d-x 3.0 在C++中调用lua函数
代码用的是<cocos2d-x 3.0 在lua中调用自定义类>中的代码. 在上篇的基础上进行扩充. 写lua函数 local function process_packet(user_d ...
- PyCharm 基础设置
设置主题:File -- Settings -- Editor -- Color & Fonts -- Font -- Scheme 设置为 Darcula 设置字体:File -- Sett ...
- 《C++标准程序库》笔记之四
本篇博客笔记顺序大体按照<C++标准程序库(第1版)>各章节顺序编排. ---------------------------------------------------------- ...
- 【delphi】Delphi过程、函数传递参数的八种方式
Delphi过程函数传递参数的八种方式
- make: Warning: File `Makefile' has modification time 17 s in the future
linux下,make makefile文件的时候报警告: make: Warning: File `Makefile' has modification time 17 s in the futur ...
- 树莓派3安装opencv2程序无法运行
在raspberry pi3 上安装opencv3已测试,没有问题,而opencv2报错如下: Xlib: extension "RANDR" missing on display ...
- 让人一看就懂的excel相对引用和绝对引用案例解析
http://www.ittribalwo.com/article/2831.html 内容提要:本文的excel相对引用和绝对引用.混合引用的使用方法案例截选自<Excel效率手册 早做完,不 ...
- 怎么使用jstack精确找到异常代码
1.代码demo //一个CPU密集型线程的demo: package chapter1; public class FindJavaThreadInTaskManager { public stat ...
- 第二步 (仅供参考) sencha touch 使用cmd打包apk
最新版本的cmd可以直接将sencha touch项目打包成本地应用,不过还有很多不足,本文仅供参考 通过sencha app build native命令可以直接将项目打包成本地应用,不过在命令运行 ...
- 生产环境mysql的参数设置不一样,好好的程序,又出错
一.概述 报错信息如下: org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: c ...