-
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
Support 'string'-style queries on metadata fields when reasonable. #34089
Conversation
Pinging @elastic/es-search-aggs |
4f8e3ce
to
7d4aafd
Compare
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.
I left some comments and am wondering why you didn't include the IdFieldType
?
|
||
Query expected = new WildcardQuery(new Term("field", new BytesRef("foo*"))); | ||
assertEquals(expected, ft.wildcardQuery("foo*", null)); | ||
} |
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.
Can you also add a test for prefix
query ?
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.
👍
|
||
Query expected = new WildcardQuery(new Term("field", new BytesRef("foo*"))); | ||
assertEquals(expected, ft.wildcardQuery("foo*", null)); | ||
} |
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.
Same here ?
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.
👍
Sorry, should've explained that in the PR description. |
Sorry I meant |
Even though we could add support for these queries to these fields, should we? The |
It looks like I might have commented too quickly and this PR is only restoring support that already existed before #34062? |
@jimczi got it, I will look into adding support for the appropriate queries to @jpountz you're right, and I maybe should've done this as part of that PR to avoid confusion. This PR restores |
Thanks @jtibshirani, I don't have objections then. +1 to discuss deprecating wildcard/prefix/range on those special fields. |
7d4aafd
to
937af2d
Compare
prefix
and wildcard
queries on metadata fields where it makes sense.
prefix
and wildcard
queries on metadata fields where it makes sense.prefix
and wildcard
queries on metadata fields when reasonable.
prefix
and wildcard
queries on metadata fields when reasonable.937af2d
to
602b9ed
Compare
@jimczi I think this is ready for another look. I added support for |
…dType. This allows them to support additional query types like prefix and wildcard.
602b9ed
to
15669af
Compare
15669af
to
0c9fefe
Compare
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.
The changes looks good and thanks for handling the _index
field as well.
After taking a closer look, I am actually a little unclear on why we want to add support for prefix to _index fields (given it's already a bit inconsistent as we don't support regexp or fuzzy queries).
It is inconsistent, I agree and I was wondering why we accept wildcard
queries but not the others. It also appears that term
and terms
query accept wildcard on the _index
field. I was not aware of that. It's not documented but now that we accept prefix
and wildcard
queries we should maybe discuss the deprecation/removal this use case. There's also a question regarding aliases but that's out of scope here.
* master: Use more precise does S3 bucket exist method (elastic#34123) LLREST: Introduce a strict mode (elastic#33708) [CCR] Adjust list retryable errors (elastic#33985) Fix AggregationFactories.Builder equality and hash regarding order (elastic#34005) MINOR: Remove some deadcode in NodeEnv and Related (elastic#34133) Rest-Api-Spec: Correct spelling in filter_path description (elastic#33154) Core: Don't rely on java time for epoch seconds formatting (elastic#34086) Retry errors when fetching follower global checkpoint. (elastic#34019) Watcher: Reenable watcher stats REST tests (elastic#34107) Remove special-casing of Synonym filters in AnalysisRegistry (elastic#34034) Rename CCR APIs (elastic#34027) Fixed CCR stats api serialization issues and (elastic#33983) Support 'string'-style queries on metadata fields when reasonable. (elastic#34089) Logging: Drop Settings from security logger get calls (elastic#33940) SQL: Internal refactoring of operators as functions (elastic#34097)
…34089) * Make sure 'ignored' and 'routing' field types inherit from StringFieldType. * Add tests for prefix and regexp queries. * Support prefix and regexp queries on _index fields.
…34089) * Make sure 'ignored' and 'routing' field types inherit from StringFieldType. * Add tests for prefix and regexp queries. * Support prefix and regexp queries on _index fields.
We speculatively added support for `regexp` queries on the `_index` field in #34089 (this functionality was not actually requested by a user). Supporting regex logic adds complexity to the `_index` field for not much gain, so we would like to remove it. From an end-to-end test it turns out this functionality never even worked in the first place because of an error in how regex flags were interpreted! For this reason, we can remove support for `regexp` on `_index` without a deprecation period. Relates to #46640.
We speculatively added support for `regexp` queries on the `_index` field in #34089 (this functionality was not actually requested by a user). Supporting regex logic adds complexity to the `_index` field for not much gain, so we would like to remove it. From an end-to-end test it turns out this functionality never even worked in the first place because of an error in how regex flags were interpreted! For this reason, we can remove support for `regexp` on `_index` without a deprecation period. Relates to #46640.
This change has two components:
prefix
andregexp
queries on_index
fields for consistency, since we already supportwildcard
queries.ignored
androuting
field types to inherit fromStringFieldType
, which allows them to support 'string'-style queries likeprefix
,regex
, andwildcard
. We temporarily removed support forwildcard
as part of the refactor in Delegate wildcard query creation to MappedFieldType. #34062, and this PR restores that support for compatibility, and also makes sure the other query types are implemented for consistency.Note that we may eventually deprecate support for 'string'-style queries on
ignored
androuting
fields, pending a separate discussion.