-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add match_only_text
, a space-efficient variant of text
.
#66172
Merged
jpountz
merged 28 commits into
elastic:master
from
jpountz:feature/source_phrase_queries
Apr 22, 2021
Merged
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0bfd387
Add `match_only_text`, a space-efficient variant of `text`.
jpountz 6b0cb21
iter
jpountz 7525e4f
Merge branch 'master' into feature/source_phrase_queries
jpountz e57699e
Use source lookup from the shard context.
jpountz 9ec31c6
Update release version.
jpountz 7a03a0f
Consolidate docs with `text`.
jpountz 5774bc9
Fail phrase queries when _source is disabled.
jpountz c0be502
Remove support for `store`.
jpountz feaf2f8
Add tests for span and intervals queries.
jpountz d51db6c
Test for fuzzy query.
jpountz 71adb75
More tests.
jpountz 4f33106
Merge branch 'master' into feature/source_phrase_queries
jpountz 24b345e
Fix compilation.
jpountz 34743ef
iter
jpountz efdb3ba
Merge branch 'master' into feature/source_phrase_queries
jpountz 7114fdc
iter
jpountz 2030545
iter
jpountz 96f668b
Merge branch 'master' into feature/source_phrase_queries
jpountz 3a85af4
iter
jpountz 448eb28
iter
jpountz f3e77f8
Fix compilation.
jpountz c5f4f04
Analysis is no longer configurable.
jpountz 4818edc
iter
jpountz 339c8dc
Merge branch 'master' into feature/source_phrase_queries
jpountz e652aa4
Intervals unit tests.
jpountz 31a5bba
Fix docs now that `match_only_text` supports all interval queries.
jpountz 3783f18
Undo testing hack.
jpountz edaa5b0
Merge branch 'master' into feature/source_phrase_queries
jpountz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
[role="xpack"] | ||
[testenv="basic"] | ||
|
||
[discrete] | ||
[[match-only-text-field-type]] | ||
=== Match-only text field type | ||
|
||
A variant of <<text,`text`>> that trades scoring and efficiency of positional | ||
queries for space efficiency. This field effectively stores data the same way as | ||
a `text` field that only indexes documents (`index_options: docs`) and disables | ||
norms (`norms: false`). Term queries perform as fast if not faster as on `text` | ||
fields, however queries that need positions such as the | ||
<<query-dsl-match-query-phrase,`match_phrase` query>> perform slower as they | ||
need to look at the `_source` document to verify whether a phrase matches. All | ||
queries return constant scores that are equal to 1.0. | ||
|
||
[source,console] | ||
-------------------------------- | ||
PUT logs | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
}, | ||
"message": { | ||
"type": "match_only_text" | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------- | ||
|
||
`match_only_text` supports the same queries as `text`. And like `text`, it | ||
doesn't support sorting or aggregating. | ||
|
||
[discrete] | ||
[[match-only-text-params]] | ||
==== Parameters for match-only text fields | ||
|
||
The following mapping parameters are accepted: | ||
|
||
[horizontal] | ||
|
||
<<analyzer,`analyzer`>>:: | ||
|
||
The <<analysis,analyzer>> which should be used for | ||
the `text` field, both at index-time and at | ||
search-time (unless overridden by the <<search-analyzer,`search_analyzer`>>). | ||
Defaults to the default index analyzer, or the | ||
<<analysis-standard-analyzer,`standard` analyzer>>. | ||
|
||
<<multi-fields,`fields`>>:: | ||
|
||
Multi-fields allow the same string value to be indexed in multiple ways for | ||
different purposes, such as one field for search and a multi-field for | ||
sorting and aggregations, or the same string value analyzed by different | ||
analyzers. | ||
|
||
<<mapping-field-meta,`meta`>>:: | ||
|
||
Metadata about the field. | ||
|
||
<<search-analyzer,`search_analyzer`>>:: | ||
|
||
The <<analyzer,`analyzer`>> that should be used at search time on | ||
the `text` field. Defaults to the `analyzer` setting. | ||
|
||
<<search-quote-analyzer,`search_quote_analyzer`>>:: | ||
|
||
The <<analyzer,`analyzer`>> that should be used at search time when a | ||
phrase is encountered. Defaults to the `search_analyzer` setting. | ||
|
||
<<mapping-store,`store`>>:: | ||
|
||
Whether the field value should be stored and retrievable separately from | ||
the <<mapping-source-field,`_source`>> field. Accepts `true` or `false` | ||
(default). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
server/src/main/java/org/elasticsearch/common/CheckedIntFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.common; | ||
|
||
@FunctionalInterface | ||
public interface CheckedIntFunction<T, E extends Exception> { | ||
T apply(int input) throws E; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apply plugin: 'elasticsearch.esplugin' | ||
apply plugin: 'elasticsearch.internal-cluster-test' | ||
|
||
esplugin { | ||
name 'match-only-text' | ||
description 'Module for the match-only-text field type, which is a specialization of text field for the case when scoring is not needed and space efficiency is important.' | ||
classname 'org.elasticsearch.xpack.matchonlytext.MatchOnlyTextMapperPlugin' | ||
extendedPlugins = ['x-pack-core'] | ||
} | ||
archivesBaseName = 'x-pack-match-only-text' | ||
|
||
dependencies { | ||
compileOnly project(path: xpackModule('core'), configuration: 'default') | ||
internalClusterTestImplementation project(path: xpackModule('core'), configuration: 'testArtifacts') | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thought I had since reviewing: if this is just targeted at log lines, would it make sense to cut down on analysis config options? For example, not allowing for a different search analyzer or search quote analyzers. Or even removing the option configuring the analyzer, just using a default that targets log lines. This could make it simpler to maintain long BWC for the field type. (This is a rough idea, and I am not sure it makes sense... maybe many users in fact tweak analyzers for log lines.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it's a good call, e.g. as far as I know, ECS doesn't configure analyzers. It would be much easier to add it in the future if it proves needed than to remove it when we want to ease backward compatibility.