Skip to content

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.

Relates to #10217

PR goes agains query-refactoring feature branch.

* @return an immutable list copy of the current sub-queries of this disjunction
*/
public List<QueryBuilder> queries() {
return ImmutableList.copyOf(this.queries);
Copy link
Member

Choose a reason for hiding this comment

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

curious about making a copy here. Did we do this in other queries too? You went this path to prevent users from making changes to the list that we might return instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that was my reasoning. I think I haven't seen it in other queries, what do you think, should we use this also elsewhere or is this too restrictive?

Copy link
Member

Choose a reason for hiding this comment

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

I dunno, I think we should do the same in all queries though, whatever we decide to do. we have a public method to add queries, so this list can be modified from the outside, why can't we just return the same list through getter? What is the advantage of making a copy here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do as in BoolQueryBuilder then.

@javanna
Copy link
Member

javanna commented Jun 18, 2015

left a couple of comments

@cbuescher cbuescher force-pushed the feature/query-refactoring-dismax branch from e3ecde7 to 8fa73da Compare June 18, 2015 12:32
parseContext.addNamedQuery(queryName, query);
}
return query;
disMaxQuery.validate();
Copy link
Member

Choose a reason for hiding this comment

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

shall we drop the validate call?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, missed that one. I also deleted it from BoolQueryParser I think. Will do so when I spot it in other places except tests.

@cbuescher cbuescher force-pushed the feature/query-refactoring-dismax branch from 8fa73da to 9f6d3dc Compare June 18, 2015 12:51
* @throws IOException
* @throws QueryParsingException
*/
public void testNoInnerQueries() throws QueryParsingException, 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 just for consistency?

@javanna
Copy link
Member

javanna commented Jun 18, 2015

left a few minor comments, LGTM besides those!

@cbuescher cbuescher force-pushed the feature/query-refactoring-dismax branch from 9f6d3dc to 5c78cf9 Compare June 18, 2015 13:08
@cbuescher
Copy link
Member Author

Addressed last comment. I wouldn't force all query builders to overwrite validation method at this point. As far as I can see, only RangeQueryBuilder and BaseTermQueryBuilder really overwrite this in a meaningful way so far. What about even removing all the empty implementations in the spirit of "less code is good" and only add it if needed later?

Moving the query building functionality from the parser to the builders
new toQuery() method analogous to other recent query refactorings.

Relates to elastic#10217
Closes elastic#11703
@cbuescher cbuescher force-pushed the feature/query-refactoring-dismax branch from 5c78cf9 to 3f4b493 Compare June 18, 2015 13:46
@cbuescher
Copy link
Member Author

Rebased, added validate() to builder and introduced default tie breaker as a constant.

@javanna
Copy link
Member

javanna commented Jun 18, 2015

LGTM

cbuescher added a commit that referenced this pull request Jun 18, 2015
…smax

Query Refactoring: DisMaxQueryBuilder and Parser
@cbuescher cbuescher merged commit 4204927 into elastic:feature/query-refactoring Jun 18, 2015
@kevinkluge kevinkluge removed the review label Jun 18, 2015
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.

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

Query Refactoring: DisMaxQueryBuilder and Parser
@cbuescher cbuescher deleted the feature/query-refactoring-dismax 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
: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.

4 participants