Skip to content

Remove QueryParseContext from parsing QueryBuilders#25448

Merged
cbuescher merged 2 commits intoelastic:masterfrom
cbuescher:remove-QueryParseContext-p1
Jun 29, 2017
Merged

Remove QueryParseContext from parsing QueryBuilders#25448
cbuescher merged 2 commits intoelastic:masterfrom
cbuescher:remove-QueryParseContext-p1

Conversation

@cbuescher
Copy link
Copy Markdown
Member

@cbuescher cbuescher commented Jun 28, 2017

Currently QueryParseContext is only a thin wrapper around an XContentParser that
adds little functionality of its own. It only provides helpers for long deprecated
field names which can be removed, and two helper methods that can be made static
and moved to other classes. This is a first step in helping to remove
QueryParseContext.

Currently QueryParseContext is only a thin wrapper around an XContentParser that
adds little functionality of its own. I provides helpers for long deprecated
field names which can be removed and two helper methods that can be made static
and moved to other classes. This is a first step in helping to remove
QueryParseContext entirely.
@@ -42,75 +34,4 @@ public QueryParseContext(XContentParser parser) {
public XContentParser parser() {
return this.parser;
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm leaving this stub of the class here for now, otherwise the PR would have gotten very big. I have a follow up almost ready that removes the whole class, but that requires removal from all kinds of method signatures, aggregations etc...

Copy link
Copy Markdown
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

I think now is a good time for this!

it's happening

while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (parseContext.isDeprecatedSetting(currentFieldName)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This breaks 1.x compatibility, which seems fine to me! Probably worth adding a note to the migration docs just in case.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will add a short note about those two fields.

* Creates a new {@link QueryBuilder} from the query held by the {@link QueryParseContext}
* in {@link org.elasticsearch.common.xcontent.XContent} format
* Creates a new {@link QueryBuilder} from the query held by the
* {@link QueryParseContext} in
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not longer correct - more like "Creates a new QueryBuilder from the query represented by the xcontent in the parser." or something.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sure

* the input parse context. The state on the parser contained in
* this context will be changed as a side effect of this method
* call
* @param parser
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At this point I don't know that @param adds anything either.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sure

}
}

public void testParseInnerQueryBuilder() throws IOException {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably worth moving this to AbstractQueryBuilder.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Already part of a follow-up PR. I can do it now if you prefer, but the test is split there anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Part of the followup is fine with me!

@nik9000
Copy link
Copy Markdown
Member

nik9000 commented Jun 29, 2017

Very happy to have this coming in! Glad to see the end of this tunnel.

@cbuescher
Copy link
Copy Markdown
Member Author

@nik9000 thanks for the review, after this context is gone there might be possibilities for more cleanups down the road.

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Jun 29, 2017

Awesome that this can go!!!

@cbuescher cbuescher merged commit 927111c into elastic:master Jun 29, 2017
jasontedor added a commit that referenced this pull request Jun 30, 2017
* master: (129 commits)
  Add doc note regarding explicit publish host
  Fix typo in name of test
  Add additional test for sequence-number recovery
  WrapperQueryBuilder should also rewrite the parsed query.
  Remove dead code and stale Javadoc
  Update defaults in documentation (#25483)
  [DOCS] Add docs-dir to Painless (#25482)
  Add concurrent deprecation logger test
  [DOCS] Update shared attributes for Elasticsearch (#25479)
  Use LRU set to reduce repeat deprecation messages
  Add NioTransport threads to thread name checks (#25477)
  Add shortcut for AbstractQueryBuilder.parseInnerQueryBuilder to QueryShardContext
  Prevent channel enqueue after selector close (#25478)
  Fix Java 9 compilation issue
  Remove unregistered `transport.netty.*` settings (#25476)
  Handle ping correctly in NioTransport (#25462)
  Tests: Remove platform specific assertion in NioSocketChannelTests
  Remove QueryParseContext from parsing QueryBuilders (#25448)
  Promote replica on the highest version node (#25277)
  test: added not null assertion
  ...
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query DSL labels Feb 14, 2018
@cbuescher cbuescher deleted the remove-QueryParseContext-p1 branch November 27, 2025 10:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>breaking-java :Search/Search Search-related issues that do not fall into other categories v6.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants