-
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
Deprecate mlt, in and geo_bbox query name shortcuts #17507
Deprecate mlt, in and geo_bbox query name shortcuts #17507
Conversation
This does not even compile at the moment, it is just a prototype to share with @colings86 @nik9000 and @cbuescher can have a look before I go ahead with the change. I moved only the newer registration method to ParseField to minimize the work at this first stage. |
@@ -82,6 +83,98 @@ public void testRegisterQueryParserDuplicate() { | |||
} | |||
} | |||
|
|||
public void testRegisteredQueries() { | |||
//TODO rework test | |||
/*SearchModule module = new SearchModule(Settings.EMPTY, new NamedWriteableRegistry()); |
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 will fix this test once we settle on how things should look, but the idea is to have here a test that verifies which queries get registered, and duplicate all the query names. I think this is the only safe way to make sure that nothing gets lost.
@javanna I left a couple of comments but I like it |
} | ||
oldValue = parseFieldsMap.putIfAbsent(name, query.parseField); | ||
if (oldValue != null) { | ||
throw new IllegalArgumentException("Query parser [" + oldValue + "] already registered for name [" + name + |
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.
nit: Query parse field?
I also think this looks good, two minor comments, the second is also just idea maybe for future improvements, don't know if that would work currently. |
8ed6319
to
221e8dd
Compare
@@ -63,6 +63,10 @@ | |||
/** The default name for the match query */ | |||
public static final String NAME = "match"; | |||
|
|||
//TODO all these alternate names are now deprecated but the MatchQueryBuilder code needs to be updated. |
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.
this is for #17508 which I think should go in first. otherwise we deprecate before having an alternative.
I updated the PR and removed the WIP label. I addressed all comments, don't get fooled by the size, it's the same small change all over the place, plus some line length problems addressed while I was at it. Most of the change is in SearchModule, where I made some of the changes that Nik made as part of #17458. We also have a test for registered queries in SearchModuleTests, let me know what you think! |
@@ -6,7 +6,7 @@ set of documents. In order to do so, MLT selects a set of representative terms | |||
of these input documents, forms a query using these terms, executes the query | |||
and returns the results. The user controls the input documents, how the terms | |||
should be selected and how the query is formed. `more_like_this` can be | |||
shortened to `mlt`. | |||
shortened to `mlt` (deprecated, use `more_like_this` rather than `mlt`). |
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 this have a version attached?
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.
yea I'll have to figure out how to do that, I forgot
I'm fine with the code. We'll need to add stuff to the breaking changes docs I think. As well as put the versions when things were deprecated in the docs. |
I took a look, this looks good to me. |
but nothing is breaking here :) I am not sure whether we have a deprecation list somewhere, I will ask around. |
The breaking changes list is the deprecated list, iirc. |
} | ||
|
||
private <QB extends QueryBuilder<QB>> void innerRegisterQueryParser(QueryParser<QB> parser, ParseField queryName) { | ||
Tuple<ParseField, QueryParser<?>> parseFieldQueryParserTuple = new Tuple<>(queryName, parser); |
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.
To me, this logic should really be in IndicesQueriesRegistry
so we construct the registry with just the Settings
object and then call a registerQuery(ParseField, QueryParser<?>)
method which unpacks the ParseField
and adds it to the registry map. That was the registry is dealing with how to internally structure the data and the internals can be easily changed later without affecting outside code.
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 get it I get it :) I think it is easy to move this method to the registry at this point, since we have a single step only
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 changed my mind, I think the register methods should be only here in SearchModule. The nice thing of IndicesQueriesRegistry is that it's immutable, and classes that don't depend on it do so only because they need to read from it, retrieve registered parsers. I wouldn't want to expose a register method there and make the class mutable. You see what I mean?
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.
Hmmm, I do see what you mean. Personally I would still prefer the register method in the registry but I think this is a personal preference thing rather than a substantial concern so I'm happy to yield on it 😄
@javanna I added one more comment but otherwise it LGTM |
8c2e269
to
6c4128b
Compare
LGTM |
If we have a deprecated query name, at the moment we don't have a way to log any deprecation warning nor fail when we are in strict mode. With this change we use ParseField, which will take care of the camel casing that we currently do manually (so that one day we can remove it more easily). This also means, that each query will have a unique preferred name, and all the other names are deprecated. Terms query "in" synonym is now formally deprecated, as well as fuzzy_match, match_fuzzy, match_phrase and match_phrase_prefix for match query, mlt for more_like_this and geo_bbox for geo_bounding_box. All these will be removed in 6.0. Every QueryParser holds now a ParseField constant called QUERY_NAME_FIELD that holds the name for it. The first name is the preferred one, all the others are deprecated. The first name is taken from the NAME constant already present in each query builder object, so that we somehow keep the serialization constant separated from ParseField. This change also allowed us to remove the names method from the QueryParser interface.
6c4128b
to
dae9987
Compare
If we have a deprecated query name, at the moment we don't have a way to log any deprecation warning. With this PR we use ParseField, so that we can properly deprecate query synonyms and have one single name for each query. This PR effectively deprecates
in
,mlt
andgeo_bbox
in favour of their complete namesterms
,more_like_this
andgeo_bounding_box
.