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

Adding fromXContent to Suggest and Suggestion class #23226

Merged
merged 2 commits into from
Feb 20, 2017

Conversation

cbuescher
Copy link
Member

A follow up to #23202, this adds parsing from xContent and tests to the four Suggestion implementations
and the top level suggest element to be used later when parsing the entire SearchResponse.

@cbuescher cbuescher added :Search/Search Search-related issues that do not fall into other categories >enhancement review v6.0.0-alpha1 labels Feb 17, 2017
Copy link
Member

@javanna javanna left a comment

Choose a reason for hiding this comment

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

left a couple of minors, LGTM !

suggestion = new CompletionSuggestion(name, -1);
entryParser = CompletionSuggestion.Entry::fromXContent;
break;
}
Copy link
Member

Choose a reason for hiding this comment

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

shall we add a TODO that this switch won't be needed once we introduce NamedXContentRegistry?

Copy link
Member Author

Choose a reason for hiding this comment

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

Will add a TODO to re-evaluate this. I'm not sure this fits in 100% with NamedXContentRegistry since we not only need to look up a parser but also the right constructor for the suggestion. I will add this to the comment.

Function<XContentParser, Entry> entryParser = null;
/// the "size" parameter and the SortBy for TermSuggestion cannot be parsed from the response, use default values
switch (type) {
case Suggestion.NAME:
Copy link
Member

Choose a reason for hiding this comment

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

is the indentation off here?

}
if (rarely()) {
numEntries = 0; // also occasionally test zero entries
}
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 clarify the logic here and assign the variable only once?

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


public class SuggestionTests extends ESTestCase {

@SuppressWarnings({ "unchecked", "rawtypes" })
Copy link
Member

Choose a reason for hiding this comment

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

do you get a warning without the rawtypes suppression?

Copy link
Member Author

Choose a reason for hiding this comment

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

No I don't. Ide or command line?

Copy link
Member Author

Choose a reason for hiding this comment

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

Scratch that, I misread: yes I get a warning on the map type ( Class<Suggestion>[]) but there seems to be no easy way around this. The whole generic usage in the Suggestion/Entry/Option hierarchy needs some closer look but this would be out of scope for this PR I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see that in this particular case I can remove the rawtypes suppression if I do Class<Suggestion<? extends Entry<? extends Option>>>[] - not nice but I'll update that.

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 just wondering if it's IDE configuration. does everything compile and build without the suppression? Asking because I am not sure we generally add those type of suppressions, but I may be wrong.

@cbuescher
Copy link
Member Author

@javanna thanks for the review, I added a small update and will wait for CI to finish

@cbuescher cbuescher merged commit ea7deac into elastic:master Feb 20, 2017
cbuescher added a commit that referenced this pull request Feb 21, 2017
A follow up to #23202, this adds parsing from xContent and tests to the four Suggestion implementations
and the top level suggest element to be used later when parsing the entire SearchResponse.
@cbuescher
Copy link
Member Author

Merged to 5.x with 1b44fe5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search/Search Search-related issues that do not fall into other categories v5.4.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants