Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors TypeQuery #12035

Conversation

alexksikes
Copy link
Contributor

Relates to #10217

This PR is against the query-refactoring branch.

this.type = type;
}

public TypeQueryBuilder() {
Copy link
Member

Choose a reason for hiding this comment

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

can we make this constructor private? null should not be an allowed value from the outside right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes but you could always do new TypeQueryBuilder((String) null)

@javanna
Copy link
Member

javanna commented Jul 6, 2015

left a few comments

@alexksikes
Copy link
Contributor Author

@javanna Thanks for the review. I updated the PR accordingly.

this.type = BytesRefs.toBytesRef(type);
}

public TypeQueryBuilder(BytesRef type) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could make this constructor package private, given that only our own parser will use it, while the java api exposes the existing one that takes a String as argument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will do.

@javanna
Copy link
Member

javanna commented Jul 14, 2015

did another round, left some comments

@alexksikes
Copy link
Contributor Author

@javanna I updated the PRs and responded to the comments.

if (randomTypes.length == 0) {
return MetaData.ALL;
}
return randomFrom(randomTypes);
Copy link
Member

Choose a reason for hiding this comment

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

I think the whole method could just be:

return randomBoolean ? MetaData.ALL : randomFrom(currentTypes);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can't random pick from an empty array.

Copy link
Member

Choose a reason for hiding this comment

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

then handle when currentTypes is empty and make it all, but don't call getRandomTypes for nothing. Why would you need to create an array composed of a random number of types out of the current types, to then keep only one. Just keep one from original array? Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh I see yes I should directly access currentTypes instead.

@alexksikes alexksikes force-pushed the feature/query-refactoring-type-query branch from d6d3818 to 81b54e2 Compare July 24, 2015 10:00
@alexksikes
Copy link
Contributor Author

@javanna it's rebased, you can take a look. Thank you.

@javanna
Copy link
Member

javanna commented Jul 24, 2015

LGTM

Relates to elastic#10217
Closes elastic#12035

This PR is against the query-refactoring branch.
@alexksikes alexksikes force-pushed the feature/query-refactoring-type-query branch from 81b54e2 to 4d4dc5c Compare July 24, 2015 10:12
@alexksikes alexksikes merged commit 4d4dc5c into elastic:feature/query-refactoring Jul 24, 2015
@alexksikes alexksikes deleted the feature/query-refactoring-type-query branch July 24, 2015 10:13
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
Relates to elastic#10217
Closes elastic#12035

This PR is against the query-refactoring branch.
@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.

3 participants