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

Query refactoring: IdsQuery #10670

Conversation

cbuescher
Copy link
Member

Split the parse(QueryParseContext ctx) method into a parsing and a query building part, adding Streamable for serialization and hashCode(), equals() for better testing.
Add basic unit test for Builder and Parser.

PR goes agains query-refacoring feature branch.


private String queryName;
String queryName;
Copy link
Member

Choose a reason for hiding this comment

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

comment about visibility too, why not private with getters?

@cbuescher cbuescher force-pushed the feature/query-refactoring-idsquery branch 2 times, most recently from 7eacb55 to 6551fe7 Compare May 5, 2015 13:55
@cbuescher
Copy link
Member Author

I rebased this PR on current state of feature branch, added the changes to BaseQuery and the QueryBuilder interface that we already discussed in #10669.

@cbuescher cbuescher self-assigned this May 5, 2015
@@ -108,4 +149,84 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
protected String parserName() {
return IdsQueryParser.NAME;
}

public Query toQuery(QueryParseContext parseContext) throws IOException, QueryParsingException {
ArrayList<BytesRef> ids = new ArrayList<>();
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 init the arraylist providing its size as input since we know it? also maybe use List on the left side?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@javanna
Copy link
Member

javanna commented May 5, 2015

I quickly went through it and it LGTM besides the few minor comments I left. @dakrone can you have another look too please?

@cbuescher cbuescher force-pushed the feature/query-refactoring-idsquery branch from 6551fe7 to a00966b Compare May 6, 2015 13:09
@cbuescher
Copy link
Member Author

Added changes adressing the comments and rebased on current feature branch. Will wait for another look from @dakrone.

@cbuescher cbuescher force-pushed the feature/query-refactoring-idsquery branch from a00966b to 81e1ca9 Compare May 6, 2015 13:30

private String queryName;

public IdsQueryBuilder(String... types) {
this.types = types == null ? null : Arrays.asList(types);
this.types = (types == null || types.length == 0) ? new ArrayList<String>() : Arrays.asList(types);
Copy link
Member

Choose a reason for hiding this comment

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

you dont need the type here new ArrayList<>() right? your IDE should give you a warning for this type of things.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I get a compile error when I don't use the type here. Maybe because of the ternary operator here.

@javanna
Copy link
Member

javanna commented May 6, 2015

I just had another look, left a few comments

@cbuescher cbuescher force-pushed the feature/query-refactoring-idsquery branch 2 times, most recently from b749dbc to 475c083 Compare May 7, 2015 14:58
@cbuescher
Copy link
Member Author

Went over the comments and added serialization of string lists to the StreamInput/Output classes, also added test for checking exception on missing value field.

@cbuescher cbuescher force-pushed the feature/query-refactoring-idsquery branch from 475c083 to 73044ac Compare May 7, 2015 15:07
* @throws IOException
*/
@Test(expected=QueryParsingException.class)
public void idsNotProvided() throws IOException {
Copy link
Member

Choose a reason for hiding this comment

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

can you prepend the name of the method with test, just to make sure?

@cbuescher cbuescher force-pushed the feature/query-refactoring-idsquery branch from 297dab3 to f4df5a0 Compare May 8, 2015 13:06
@cbuescher
Copy link
Member Author

Just rebased this on current state of feature branch which now includes the addition if streaming string lists & adressed the last two comments.

@javanna
Copy link
Member

javanna commented May 8, 2015

LGTM

cbuescher added a commit that referenced this pull request May 8, 2015
Split the parse(QueryParseContext ctx) method into a parsing and a query building part,
adding Streamable for serialization and hashCode(), equals() for better testing.
Add basic unit test for Builder and Parser.

Closes #10670
@cbuescher cbuescher closed this May 8, 2015
mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
Split the parse(QueryParseContext ctx) method into a parsing and a query building part,
adding Streamable for serialization and hashCode(), equals() for better testing.
Add basic unit test for Builder and Parser.

Closes elastic#10670
@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-idsquery 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
: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