`
m635674608
  • 浏览: 5069292 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

es Queries and filters

 
阅读更多

Query DSL changesedit

  • Elasticsearch Reference:

Queries and filters mergededit

Queries and filters have been merged — all filter clauses are now query clauses. Instead, query clauses can now be used in query context or in filter context:

Query context
A query used in query context will calculate relevance scores and will not be cacheable. Query context is used whenever filter context does not apply.
Filter context

A query used in filter context will not calculate relevance scores, and will be cacheable. Filter context is introduced by:

  • the constant_score query
  • the must_not and (newly added) filter parameter in the bool query
  • the filter and filters parameters in the function_score query
  • any API called filter, such as the post_filter search parameter, or in aggregations or index aliases

terms query and filteredit

The execution option of the terms filter is now deprecated and is ignored if provided. Similarly, the terms query no longer supports the minimum_should_match parameter.

or and and now implemented via booledit

The or and and filters previously had a different execution pattern to the bool filter. It used to be important to use and/or with certain filter clauses, and bool with others.

This distinction has been removed: the bool query is now smart enough to handle both cases optimally. As a result of this change, the or and and filters are now sugar syntax which are executed internally as a bool query. These filters may be removed in the future.

filtered query and query filter deprecatededit

The query filter is deprecated as is it no longer needed — all queries can be used in query or filter context.

The filtered query is deprecated in favour of the bool query. Instead of the following:

GET _search
{"query":{"filtered":{"query":{"match":{"text":"quick brown fox"}},"filter":{"term":{"status":"published"}}}}}

move the query and filter to the must and filter parameters in the bool query:

GET _search
{"query":{"bool":{"must":{"match":{"text":"quick brown fox"}},"filter":{"term":{"status":"published"}}}}}

Filter auto-cachingedit

It used to be possible to control which filters were cached with the _cache option and to provide a custom _cache_key. These options are deprecated and, if present, will be ignored.

Query clauses used in filter context are now auto-cached when it makes sense to do so. The algorithm takes into account the frequency of use, the cost of query execution, and the cost of building the filter.

The terms filter lookup mechanism no longer caches the values of the document containing the terms. It relies on the filesystem cache instead. If the lookup index is not too large, it is recommended to replicate it to all nodes by setting index.auto_expand_replicas: 0-all in order to remove the network overhead as well.

Numeric queries use IDF for scoringedit

Previously, term queries on numeric fields were deliberately prevented from using the usual Lucene scoring logic and this behaviour was undocumented and, to some, unexpected.

Single term queries on numeric fields now score in the same way as string fields, using IDF and norms (if enabled).

To query numeric fields without scoring, the query clause should be used in filter context, e.g. in the filter parameter of the bool query, or wrapped in a constant_score query:

GET _search
{"query":{"bool":{"must":[{"match":{"numeric_tag":5}}],"filter":[{"match":{"count":5}}]}}}

This clause would include IDF in the relevance score calculation.

This clause would have no effect on the relevance score.

Fuzziness and fuzzy-like-thisedit

Fuzzy matching used to calculate the score for each fuzzy alternative, meaning that rare misspellings would have a higher score than the more common correct spellings. Now, fuzzy matching blends the scores of all the fuzzy alternatives to use the IDF of the most frequently occurring alternative.

Fuzziness can no longer be specified using a percentage, but should instead use the number of allowed edits:

  • 0, 1, 2, or
  • AUTO (which chooses 0, 1, or 2 based on the length of the term)

The fuzzy_like_this and fuzzy_like_this_field queries used a very expensive approach to fuzzy matching and have been removed.

More Like Thisedit

The More Like This (mlt) API and the more_like_this_field (mlt_field) query have been removed in favor of the more_like_this query.

The parameter percent_terms_to_match has been removed in favor of minimum_should_match.

limit filter deprecatededit

The limit filter is deprecated and becomes a no-op. You can achieve similar behaviour using the terminate_after parameter.

Java plugins registering custom queriesedit

Java plugins that register custom queries can do so by using the IndicesQueriesModule#addQuery(Class<? extends QueryParser>) method. Other ways to register custom queries are not supported anymore.

 

 

https://www.elastic.co/guide/en/elasticsearch/reference/2.2/breaking_20_query_dsl_changes.html#_queries_and_filters_merged

分享到:
评论

相关推荐

    ES查询客户端,elasticsearch可视化工具 elasticsearch查询客户端

    Elasticsearch(简称ES)是一款强大的开源搜索引擎,广泛应用于数据检索、分析和管理。作为分布式、RESTful风格的搜索和数据分析引擎,Elasticsearch能够提供实时、高可用性以及可扩展的搜索功能。在进行日常的数据...

    ElasticSearch SQL 教程

    If you (or others you know) are versed in SQL statements and newer to the Elasticsearch query syntax but want to benefit from the power Elasticsearch, this is the talk for you. After making its debut ...

    (狂神)ElasticSearch快速入门笔记,ElasticSearch基本操作以及爬虫(Java-ES仿京东实战)

    (狂神)ElasticSearch快速入门笔记,ElasticSearch基本操作以及爬虫(Java-ES仿京东实战),包含了小狂神讲的东西,特别适合新手学习,笔记保存下来可以多看看。好记性不如烂笔头哦~,ElasticSearch,简称es,es是一个...

    Windows版本(8.11)ElasticSearch、elasticsearch-head、kibana、IK分词

    **Elasticsearch 8.11 for Windows** Elasticsearch 是一个开源的分布式搜索引擎,以其高可伸缩性、实时性、灵活性以及强大的数据分析能力而闻名。在Windows平台上部署Elasticsearch,用户可以利用其强大的搜索和...

    ES客户端+谷歌浏览器插件+Multi-Elasticsearch-Head

    多弹性搜索头,对著名的 Elasticsearch Head 的改进 1.保存和存储几个Elasticsearch端点 2.索引选项卡中的更多列 3. 任何请求现在都可以像 /_cat/indices 一样处理 JSON 返回 4. 更简约的外观(更小的字体等...) ...

    ElasticSearch Java API 中文文档

    8. **查询DSL (Query DSL)**: 详细介绍了ElasticSearch的查询语言(Domain Specific Language),包括全量查询(Match All Query)、全文查询(Full Text Queries)、词项级查询(Term level queries)、复合查询...

    Learning Elasticsearch 【含代码】

    You will install and set up Elasticsearch and its related plugins, and handle documents using the Distributed Document Store. You will see how to query, search, and index your data, and perform ...

    elasticSearch(ES)最新版 ik分词插件7.10 elasticsearch-analysis-ik-7.10.0

    Elasticsearch(ES)是一种流行的开源全文搜索引擎,它基于Lucene构建,提供了分布式、RESTful风格的搜索和分析引擎服务。在中文环境下,为了实现精确的分词和搜索,我们需要安装适合版本的分词插件,如“elastic...

    elasticsearch elasticsearch-6.2.2 elasticsearch-6.2.2.zip 下载

    根据提供的文件信息,我们可以推断出本篇文章将围绕Elasticsearch 6.2.2版本进行详细介绍,包括其下载方式、主要功能特性以及在实际应用中的常见用途。 ### Elasticsearch简介 Elasticsearch是一款基于Lucene的...

    Elasticsearch.Essentials.1784391018.pdf

    Harness the power of ElasticSearch to build and manage scalable search and analytics solutions with this fast-paced guide About This Book New to ElasticSearch? Here's what you need―a highly ...

    7.17.1系列Elasticsearch的elasticsearch-analysis-ik分词器

    适用于7.17.1系列,例如Elasticsearch的7.17.12版本。 elasticsearch-analysis-ik 是一个常用的中文分词器,在 Elasticsearch 中广泛应用于中文文本的分析和搜索。下面是 elasticsearch-analysis-ik 分词器的几个...

    elasticsearch 8.11.3 windows安装包

    Elasticsearch 是位于 Elastic Stack 核心的分布式搜索和分析引擎。Logstash 和 Beats 有助于收集、聚合和丰富您的数据并将其存储在 Elasticsearch 中。Kibana 使您能够以交互方式探索、可视化和分享对数据的见解,...

    es-head Elasticsearch的可视化操作插件

    es-head是一个针对Elasticsearch的可视化操作插件。它提供了一个便捷的操作工具,可以连接Elasticsearch搜索引擎,并提供可视化的操作页面,对Elasticsearch进行各种设置和数据检索功能的管理。 es-head 插件可以在...

    Elasticsearch 开机自启脚本

    `start` 用于启动Elasticsearch,这里使用 `su` 命令切换到指定的Elasticsearch用户(例如 `es-admin`),然后进入Elasticsearch的安装目录并执行 `bin/elasticsearch` 文件以后台模式启动服务。`stop` 通过查找并杀...

    Elastic Search搭建使用教程.pdf(内含ElasticSearch教程权威指南)

    Elasticsearch是一款基于Lucene的开源搜索引擎,它使用RESTful接口进行数据操作,数据以JSON格式存储。Elasticsearch以其高效的全文搜索功能,实时数据处理能力,以及易于使用的特性,在众多企业中得到了广泛应用,...

    elasticsearch未授权访问 漏洞修复

    Elasticsearch 是一个流行的开源全文搜索引擎,常用于大数据分析和实时数据检索。然而,如果没有正确配置安全设置,它可能会暴露于未授权访问的风险中,这可能导致数据泄露或恶意操作。本文将详细讲解如何修复 ...

    elasticSearch-8.14.1-windows

    Elasticsearch 8.14.1 是一个高度可扩展的开源全文检索和分析引擎,专为分布式环境设计。它允许开发者和系统管理员快速、高效地存储、搜索和分析大量数据。Elasticsearch 广泛应用于日志分析、信息检索、网站搜索、...

    解决spring-data-elasticsearch 5.4.0 不支持 5.4.1的elasticsearch问题

    Spring Data Elasticsearch 5.4.0设计时可能并未考虑到与Elasticsearch 5.4.1的完全兼容,导致在升级Elasticsearch到5.4.1后,系统报出"NoNodeAvailableException"错误,提示无法连接到任何节点。这个问题主要是由于...

Global site tag (gtag.js) - Google Analytics