Skip to content

Conversation

cbuescher
Copy link
Member

Currently there is a registry for all QueryParsers accessible via the IndicesQueriesModule. For deserializing nested queries e.g. for the BoolQueryBuilder (#11121) we need to look up query builders by their name to be able to deserialize using a prototype builder of the concrete class. This PR adds a getBuilderPrototype() method to each query parser so we can re-use the parser registry to get the corresponding builder using the query name. This might change in the future when we decide to register also builders or merger parsers and builders in a later stage of the refactoring. (see #11121 (comment)) for past discussion.

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if we should use some convention on naming, like INSTANCE or PROTOTYPE, I have no strong preference though

@javanna
Copy link
Member

javanna commented May 26, 2015

looks good, left a few comments

@cbuescher cbuescher force-pushed the feature/query-refactoring-linkParsers branch from f876767 to 2a28587 Compare May 26, 2015 13:11
@cbuescher
Copy link
Member Author

@javanna had another round, moved the constants to the builders and reverted most of the package private constructors, only introduced private constructors where needed.

@javanna
Copy link
Member

javanna commented May 26, 2015

LGTM thanks @cbuescher

…rsers

Currently there is a registry for all QueryParsers accessible via the IndicesQueriesModule.
For deserializing nested queries e.g. for the BoolQueryBuilder (elastic#11121) we need to look up
query builders by their name to be able to deserialize using a prototype builder of the concrete
class. This PR adds a getBuilderPrototype() method to each query parser so we can re-use the
parser registry to get the corresponding builder using the query name.

Closes elastic#11344
@cbuescher cbuescher force-pushed the feature/query-refactoring-linkParsers branch from e054e23 to 8a37cc2 Compare May 26, 2015 14:03
@cbuescher
Copy link
Member Author

Thanks, rebased and will merge then.

cbuescher added a commit that referenced this pull request May 26, 2015
…nkParsers

Query Refactoring: Adding getBuilderPrototype() method to all QueryParsers
@cbuescher cbuescher merged commit dd5ecfc into elastic:feature/query-refactoring May 26, 2015
@javanna
Copy link
Member

javanna commented May 26, 2015

I am marking this as breaking, as it breaks plugins that introduce custom queries by requiring their QueryParser implementation to implement the new getPrototypeBuilder method. The new method is supposed to return an empty builder instance corresponding to the parser. The builder will be used aas intermediate query object and serialized over the wire for communication between the nodes.

javanna added a commit to javanna/elasticsearch that referenced this pull request May 26, 2015
… queries

`QueryBuilder`s can be serialized being them `Writeable`. Given that we support different types of queries, which can be nested into one another, we also have to make sure  that we read and write the name of the query before the actual query fields so that we know which instance of query we have to create when de-serializing. That is why serializing a query builder will be done by calling `QueryBuilderSerializer#write`, which will serialize the name of the query before the query itself, and reading only by calling `QueryBuilderSerializer#read`, which will lookup the query in the parsers registry, retrieve its corresponding empty builder from it (`getPrototypeBuilder`) and call `readFrom` against it, which will return a new query builder containing all the de-serialized fields. Compound queries will then have to use these methods to read and write their inner queries.

The registration of custom queries via plugin doesn't change, only the parser needs to be registered still, but it has now to implement the `getPrototypeBuilder` method too introduced with elastic#11344, which returns an empy builder instance that can be used to de-serialize the query.
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
…rsers

Currently there is a registry for all QueryParsers accessible via the IndicesQueriesModule.
For deserializing nested queries e.g. for the BoolQueryBuilder (elastic#11121) we need to look up
query builders by their name to be able to deserialize using a prototype builder of the concrete
class. This PR adds a getBuilderPrototype() method to each query parser so we can re-use the
parser registry to get the corresponding builder using the query name.

Closes elastic#11344
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
…ring-linkParsers

Query Refactoring: Adding getBuilderPrototype() method to all QueryParsers
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Query Refactoring labels Feb 14, 2018
@cbuescher cbuescher deleted the feature/query-refactoring-linkParsers branch March 20, 2024 20:15
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.

3 participants