Query DSL changesedit
On this page
- Elasticsearch Reference:
- Getting Started
- Setup
-
Breaking changes
- Breaking changes in 2.2
- Breaking changes in 2.1
-
Breaking changes in 2.0
- Removed features
- Network changes
- Multiple
path.data
striping - Mapping changes
- CRUD and routing changes
- Query DSL changes
- Search changes
- Aggregation changes
- Parent/Child changes
- Scripting changes
- Index API changes
- Snapshot and Restore changes
- Plugin and packaging changes
- Setting changes
- Stats, info, and
cat
changes - Java API changes
- Breaking changes in 1.6
- Breaking changes in 1.4
- Breaking changes in 1.0
- API Conventions
- Document APIs
- Search APIs
- Aggregations
- Indices APIs
- cat APIs
- Cluster APIs
- Query DSL
- Mapping
- Analysis
- Modules
- Index Modules
- Testing
- Glossary of terms
- Release Notes
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:
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 thebool
query - the
filter
andfilters
parameters in thefunction_score
query - any API called
filter
, such as thepost_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 bool
edit
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}}]}}}
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 chooses0
,1
, or2
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
相关推荐
Elasticsearch(简称ES)是一款强大的开源搜索引擎,广泛应用于数据检索、分析和管理。作为分布式、RESTful风格的搜索和数据分析引擎,Elasticsearch能够提供实时、高可用性以及可扩展的搜索功能。在进行日常的数据...
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,简称es,es是一个...
**Elasticsearch 8.11 for Windows** Elasticsearch 是一个开源的分布式搜索引擎,以其高可伸缩性、实时性、灵活性以及强大的数据分析能力而闻名。在Windows平台上部署Elasticsearch,用户可以利用其强大的搜索和...
多弹性搜索头,对著名的 Elasticsearch Head 的改进 1.保存和存储几个Elasticsearch端点 2.索引选项卡中的更多列 3. 任何请求现在都可以像 /_cat/indices 一样处理 JSON 返回 4. 更简约的外观(更小的字体等...) ...
8. **查询DSL (Query DSL)**: 详细介绍了ElasticSearch的查询语言(Domain Specific Language),包括全量查询(Match All Query)、全文查询(Full Text Queries)、词项级查询(Term level queries)、复合查询...
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)是一种流行的开源全文搜索引擎,它基于Lucene构建,提供了分布式、RESTful风格的搜索和分析引擎服务。在中文环境下,为了实现精确的分词和搜索,我们需要安装适合版本的分词插件,如“elastic...
根据提供的文件信息,我们可以推断出本篇文章将围绕Elasticsearch 6.2.2版本进行详细介绍,包括其下载方式、主要功能特性以及在实际应用中的常见用途。 ### Elasticsearch简介 Elasticsearch是一款基于Lucene的...
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的7.17.12版本。 elasticsearch-analysis-ik 是一个常用的中文分词器,在 Elasticsearch 中广泛应用于中文文本的分析和搜索。下面是 elasticsearch-analysis-ik 分词器的几个...
Elasticsearch 是位于 Elastic Stack 核心的分布式搜索和分析引擎。Logstash 和 Beats 有助于收集、聚合和丰富您的数据并将其存储在 Elasticsearch 中。Kibana 使您能够以交互方式探索、可视化和分享对数据的见解,...
es-head是一个针对Elasticsearch的可视化操作插件。它提供了一个便捷的操作工具,可以连接Elasticsearch搜索引擎,并提供可视化的操作页面,对Elasticsearch进行各种设置和数据检索功能的管理。 es-head 插件可以在...
`start` 用于启动Elasticsearch,这里使用 `su` 命令切换到指定的Elasticsearch用户(例如 `es-admin`),然后进入Elasticsearch的安装目录并执行 `bin/elasticsearch` 文件以后台模式启动服务。`stop` 通过查找并杀...
Elasticsearch是一款基于Lucene的开源搜索引擎,它使用RESTful接口进行数据操作,数据以JSON格式存储。Elasticsearch以其高效的全文搜索功能,实时数据处理能力,以及易于使用的特性,在众多企业中得到了广泛应用,...
Elasticsearch 是一个流行的开源全文搜索引擎,常用于大数据分析和实时数据检索。然而,如果没有正确配置安全设置,它可能会暴露于未授权访问的风险中,这可能导致数据泄露或恶意操作。本文将详细讲解如何修复 ...
Elasticsearch 8.14.1 是一个高度可扩展的开源全文检索和分析引擎,专为分布式环境设计。它允许开发者和系统管理员快速、高效地存储、搜索和分析大量数据。Elasticsearch 广泛应用于日志分析、信息检索、网站搜索、...
Spring Data Elasticsearch 5.4.0设计时可能并未考虑到与Elasticsearch 5.4.1的完全兼容,导致在升级Elasticsearch到5.4.1后,系统报出"NoNodeAvailableException"错误,提示无法连接到任何节点。这个问题主要是由于...