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

Query refactoring: QueryFilterBuilder and Parser #11729

Conversation

cbuescher
Copy link
Member

Moving the query building functionality from the parser to the builders
new toQuery() method analogous to other recent query refactorings. In
this case this also includes FQueryFilterParser, since both queries are
closely related.

Relates to #10217
Closes #11729

if (queryName == null) {
return new QueryFilterBuilder(innerQueryBuilder);
} else {
return new FQueryFilterBuilder(innerQueryBuilder).queryName(queryName);
Copy link
Member

Choose a reason for hiding this comment

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

I wish we could avoid having this if, it's a PITA really, I would consider breaking java api bw comp here and move the queryName to FQueryFilterBuilder so the code is more human. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

What if we accept a little bit of code duplication and separate FQueryFilterBuilder and QueryFilterBuilder in so far as they both extend QueryBuilder. Then FQueryBuilder would be the one that has a queryName. The only thing that remains slightly odd then is that when rendering out, FQuery still uses the QueryFilterBuilder name ("query") because it essentially wraps it. But thats the state of the DSL at the moment.

@javanna
Copy link
Member

javanna commented Jun 18, 2015

left one comment, looks good!

@cbuescher cbuescher force-pushed the feature/query-refactoring-fquery branch 2 times, most recently from a5ab7d5 to 8f5cca5 Compare June 22, 2015 13:44
@cbuescher
Copy link
Member Author

With last commit I moved the queryName member which was just used for FQuery from the QueryFilterBuilder to the new FQueryFilterBuilder that we introduced on the feature branch to separate the two variants of this builder. This creates some code duplication but avoids the former confusion between the two cases. Only problem here might be that for the Java-API we slightly break the existing QueryFilterBuilder because now it doesn't support queryName() any longer, but that part conceptually belonged to FQuery anyway.

/**
* test wrapping an inner filter that returns null also returns <tt>null</null> to pass on upwards
*/
public void testInnerQueryReturnsNull() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

missing @test

Copy link
Contributor

Choose a reason for hiding this comment

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

we should @Test to forbidden API

@javanna
Copy link
Member

javanna commented Jun 22, 2015

LGTM besides the few comments I left. Looking forward to seeing these two filters removed to be honest, with the merge of filters and queries they make very little sense (only bw comp). I think we need to create a migrate_query_refactoring.asciidoc page and add our first breaking change (only for the java api).

@cbuescher
Copy link
Member Author

@javanna added asciidoc to track breaking changes on the feature branch, mind to have a look if you think this is a good location and this is verbose enough to keep track? Also, this is inteded for internal use mostly, should be merged with other migration doc when we merge with master, right?

@javanna
Copy link
Member

javanna commented Jun 22, 2015

looks great. Yes it will eventually be merged but given that we have one file per version and we don't know yet when we will merge the branch, let's just keep a separate file and decide later on what to do with it.

@cbuescher cbuescher force-pushed the feature/query-refactoring-fquery branch from feb983f to f12c4e2 Compare June 22, 2015 16:07
Moving the query building functionality from the parser to the builders
new toQuery() method analogous to other recent query refactorings. In
this case this also includes FQueryFilterParser, since both queries are
closely related.

Relates to elastic#10217
Closes elastic#11729
@cbuescher cbuescher force-pushed the feature/query-refactoring-fquery branch from f12c4e2 to b6cdc46 Compare June 22, 2015 16:17
cbuescher added a commit that referenced this pull request Jun 22, 2015
…uery

Query refactoring: QueryFilterBuilder and Parser
@cbuescher cbuescher merged commit 570022e into elastic:feature/query-refactoring Jun 22, 2015
@kevinkluge kevinkluge removed the review label Jun 22, 2015
@javanna
Copy link
Member

javanna commented Jul 1, 2015

This change is breaking for the java api as the setter QueryFilterBuilder#queryName(String queryName) has no effect anymore. _name is not supported in this type of query. Use FQueryFilterBuilder.queryName(String queryName) instead when in need to wrap a named query as a filter.

mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
Moving the query building functionality from the parser to the builders
new toQuery() method analogous to other recent query refactorings. In
this case this also includes FQueryFilterParser, since both queries are
closely related.

Relates to elastic#10217
Closes elastic#11729
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
…ring-fquery

Query refactoring: QueryFilterBuilder and Parser
@cbuescher cbuescher deleted the feature/query-refactoring-fquery branch March 31, 2016 09:26
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query Refactoring labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking :Search/Search Search-related issues that do not fall into other categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants