Skip to content
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

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Apr 4, 2016

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 and geo_bbox in favour of their complete names terms, more_like_this and geo_bounding_box.

@javanna
Copy link
Member Author

javanna commented Apr 4, 2016

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());
Copy link
Member Author

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.

@colings86
Copy link
Contributor

@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 +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Query parse field?

@cbuescher
Copy link
Member

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.

@javanna javanna force-pushed the enhancement/log_deprecation_query_names branch 2 times, most recently from 8ed6319 to 221e8dd Compare April 4, 2016 18:42
@@ -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.
Copy link
Member Author

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.

@javanna javanna added review and removed WIP labels Apr 4, 2016
@javanna
Copy link
Member Author

javanna commented Apr 4, 2016

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`).
Copy link
Member

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?

Copy link
Member Author

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

@nik9000
Copy link
Member

nik9000 commented Apr 4, 2016

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.

@cbuescher
Copy link
Member

I took a look, this looks good to me.

@javanna
Copy link
Member Author

javanna commented Apr 4, 2016

We'll need to add stuff to the breaking changes docs I think.

but nothing is breaking here :) I am not sure whether we have a deprecation list somewhere, I will ask around.

@nik9000
Copy link
Member

nik9000 commented Apr 4, 2016

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);
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Member Author

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?

Copy link
Contributor

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 😄

@colings86
Copy link
Contributor

@javanna I added one more comment but otherwise it LGTM

@javanna javanna force-pushed the enhancement/log_deprecation_query_names branch 2 times, most recently from 8c2e269 to 6c4128b Compare April 5, 2016 12:56
@colings86
Copy link
Contributor

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.
@javanna javanna force-pushed the enhancement/log_deprecation_query_names branch from 6c4128b to dae9987 Compare April 5, 2016 13:15
@javanna javanna merged commit 67ccfc3 into elastic:master Apr 5, 2016
@javanna javanna changed the title Switch to using ParseField to parse query names Deprecate mlt, in and geo_bbox query name shortcuts May 2, 2016
russcam added a commit to elastic/elasticsearch-net that referenced this pull request Jun 14, 2016
russcam added a commit to elastic/elasticsearch-net that referenced this pull request Jun 16, 2016
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>deprecation :Search/Search Search-related issues that do not fall into other categories v5.0.0-alpha2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants