Skip to content

Conversation

cbuescher
Copy link
Member

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

Relates to #10217

@cbuescher cbuescher changed the title Query refactoring: SpanNearQueryBuilder and Parser Query refactoring: SpanOrQueryBuilder and Parser Jul 20, 2015
import org.elasticsearch.common.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class SpanOrQueryBuilder extends AbstractQueryBuilder<SpanOrQueryBuilder> implements SpanQueryBuilder<SpanOrQueryBuilder> {
Copy link

Choose a reason for hiding this comment

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

Nitpick: With this turning into a public API - should we have some class level doc here?

@MaineC
Copy link

MaineC commented Jul 20, 2015

Left some minor comments.

@cbuescher
Copy link
Member Author

@MaineC thanks for the review, just pushed new commit addressing your comments. Mind to have another look?

@cbuescher cbuescher assigned MaineC and unassigned cbuescher Jul 21, 2015
@MaineC MaineC removed their assignment Jul 21, 2015
@MaineC
Copy link

MaineC commented Jul 21, 2015

LGTM - I'm sure @javanna will will find a few more areas for improvment

SpanQuery[] spanQueries = new SpanQuery[clauses.size()];
for (int i = 0; i < clauses.size(); i++) {
Query query = clauses.get(i).toQuery(parseContext);
assert query instanceof SpanQuery;
Copy link
Member

Choose a reason for hiding this comment

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

we might have the same problem with LateParsingQuery here too right? then this should become an if instead? I guess we might have the same somewhere else too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really, all query clauses here need to be SpanQueryBuilders, the problem with LateParsingQuery was related to MultiTermQueryBuilders (which RangeQuery is a subtype of). We are creating SpanOrQuery here which takes list of SpanQueries as an argument, so all good I think.

Copy link
Member

Choose a reason for hiding this comment

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

ok sorry for the confusion, here and in the other PR where I commented...

@javanna
Copy link
Member

javanna commented Jul 22, 2015

left one small comment

@cbuescher cbuescher force-pushed the feature/query-refactoring-spanor branch from 674f43f to d5954d6 Compare July 22, 2015 09:26
@cbuescher
Copy link
Member Author

Addressed comments and removed check for empty clauses in doXContent since this will either be caught by parser or in validate. Left one question regarding tests to get another opinion from @MaineC.

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

Relates to elastic#10217
@cbuescher cbuescher force-pushed the feature/query-refactoring-spanor branch from c6f24ae to 8e20536 Compare July 22, 2015 14:26
@MaineC
Copy link

MaineC commented Jul 23, 2015

After checking the modifications in person with @cbuescher this morning: Looks all good to me.

cbuescher added a commit that referenced this pull request Jul 23, 2015
…anor

Query refactoring: SpanOrQueryBuilder and Parser
@cbuescher cbuescher merged commit 026fd38 into elastic:feature/query-refactoring Jul 23, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
…ring-spanor

Query refactoring: SpanOrQueryBuilder and Parser
@cbuescher cbuescher deleted the feature/query-refactoring-spanor branch March 11, 2016 11:51
@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.

5 participants