Skip to content

Conversation

cbuescher
Copy link
Member

As part of the refactoring of queries this PR splits the parsers parse() method into a parsing and a query building part, adding serialization, hashCode(), equals() to the builder.

In addition this changes the BoostingQueryBuilder constructor from a no-arg constructor to one requiring the mandatory postive and negative query to be set, also making those fields final internally. For this reason also the setters for these two fields were deleted.

PR goes agains query-refacoring feature branch.

@cbuescher cbuescher force-pushed the feature/query-refactoring-boostingquery branch 2 times, most recently from b73dc26 to 55998ac Compare June 12, 2015 13:14
if (negativeBoost == -1) {
throw new IllegalArgumentException("boosting query requires negativeBoost to be set");
if (negativeBoost < 0) {
throw new IllegalArgumentException("boosting query requires negativeBoost to be set to positive value");
Copy link
Member

Choose a reason for hiding this comment

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

not sure, I think this error should only be returned by the validate method. Here we could print out whatever we have. The fact that we print out a query doesn't mean that it's validated? That said we might have relied on validation for previous queries in doXContent, which can be a problem... 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.

Will remove this.

@javanna
Copy link
Member

javanna commented Jun 15, 2015

left a couple of minor comments

@cbuescher
Copy link
Member Author

Just posted an update reverting the changes in the constructor and adressing other comments.

@@ -81,25 +126,87 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
if (negativeQuery == null) {
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 have these same checks in the validate method too? Or only there?

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 had them in validate() before, but the problem like in #11629 is that we need to support inner clauses that parse to null like "positive": { "constant_score": { "filter": {}}}, so if we have these checks in validate() we will throw errors on queries the DSL currently accepts.
I wonder why this behaviour was introduced in the first place, maybe there is a deeper reason for that, otherwise we should try and get rid of this but I think that's out of scope for this refactoring for now. Do you agree?

Copy link
Member

Choose a reason for hiding this comment

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

agreed, sorry I keep getting confused about this. those queries can be null, we do these checks to prevent NPEs, makes sense.

@javanna
Copy link
Member

javanna commented Jun 16, 2015

left one small comment, LGTM otherwise

As part of the refactoring of queries this PR splits the parsers parse() method
into a parsing and a query building part, adding serialization, hashCode() and
equals() to the builder.

Relates to elastic#10217
Closes elastic#11621
@cbuescher cbuescher force-pushed the feature/query-refactoring-boostingquery branch from 34bdac7 to 6202118 Compare June 16, 2015 11:57
cbuescher added a commit that referenced this pull request Jun 16, 2015
…ostingquery

Query refactoring: BoostingQueryBuilder and Parser
@cbuescher cbuescher merged commit 33668a8 into elastic:feature/query-refactoring Jun 16, 2015
@kevinkluge kevinkluge removed the review label Jun 16, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
As part of the refactoring of queries this PR splits the parsers parse() method
into a parsing and a query building part, adding serialization, hashCode() and
equals() to the builder.

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

Query refactoring: BoostingQueryBuilder and Parser
@javanna
Copy link
Member

javanna commented Aug 28, 2015

This change is breaking for the java api as it removes setters for mandatory positive/negative query. Both arguments have to be supplied at construction time instead and have to be non-null.

@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.

4 participants