Skip to content

Initial refactoring for phrase suggester #16241

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

Closed

Conversation

cbuescher
Copy link
Member

Adding initial serialization methods (readFrom, writeTo) to the PhraseSuggestionBuilder, also adding the base test framework for serialiazation testing, equals and hashCode. Moving SuggestionBuilder out of the global SuggestBuilder for better readability.

Still missing: Handling of Smoothing Model (depends on #16130) and DirectCandidateGenerator (depends on #16185). Also Test needs to be extended to handle all parameters.

@cbuescher cbuescher added review :Search Relevance/Suggesters "Did you mean" and suggestions as you type labels Jan 26, 2016
@cbuescher cbuescher force-pushed the init-phraseSuggester-refactoring branch 5 times, most recently from 6afb09c to 8440320 Compare January 27, 2016 12:59
public CompletionSuggestionBuilder prefix(String prefix) {
super.setPrefix(prefix);
super.prefix(prefix);
Copy link

Choose a reason for hiding this comment

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

Didn't we at some point want to move towards genuine getters and setters?

Copy link
Member Author

Choose a reason for hiding this comment

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

Since almost all of the setters here are not get/set I wanted to make it consistent without too much changes. I'm happy to rename them all together in one go at a later stage though. Also if anybody else objects I can change this back of course, I just don't want to change all the non-get/set type ones at this point.

Copy link

Choose a reason for hiding this comment

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

Yeah - makes sense. Maybe track the final move to get/set in a separate issue?

Copy link

Choose a reason for hiding this comment

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

What was the motivation for wanting to make them genuine "get/set" methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

@abeyad to my knowledge there was an ungoing debate. Last issue I can find is this #14266 but it also states that it might be good to do this in one go.

@MaineC
Copy link

MaineC commented Jan 27, 2016

Left a few comments. Feel free to ignore the ones about methods being empty. I didn't realize this wasn't going against master.

@cbuescher cbuescher force-pushed the init-phraseSuggester-refactoring branch 2 times, most recently from 025391f to 600a8f8 Compare January 27, 2016 14:09
@@ -91,6 +113,13 @@ public PhraseSuggestionBuilder separator(String separator) {
}

/**
* get the maxErrirs setting
Copy link
Contributor

Choose a reason for hiding this comment

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

should be "get token separator"?

Copy link
Member Author

Choose a reason for hiding this comment

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

right, thanks

@cbuescher
Copy link
Member Author

@areek @abeyad thanks for the review, I hope I adressed all of your comments, any objections about merging this then?

public abstract class SuggestionBuilder<T extends SuggestionBuilder<T>> extends ToXContentToBytes implements NamedWriteable<T> {

protected final String name;
// TODO this seems mandatory and should be constructor arg
Copy link
Contributor

Choose a reason for hiding this comment

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

++

@abeyad
Copy link

abeyad commented Jan 27, 2016

@cbuescher LGTM ++

return builder;
}

public String getSuggesterName() {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can make this private, I assume this is only for readability?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, will change that as well. And yes, currently only for readability. I hope we keep the same name constants as Id in the stream as well as for registering the parsers. That's what worked for queries at least.

@areek
Copy link
Contributor

areek commented Jan 27, 2016

@cbuescher LGTM. This looks great and thanks for the test infra :)

Adding initial serialization methods (readFrom, writeTo) to the
PhraseSuggestionBuilder, also adding the base test framework for
serialiazation testing, equals and hashCode. Moving SuggestionBuilder
out of the global SuggestBuilder for better readability.
@cbuescher cbuescher force-pushed the init-phraseSuggester-refactoring branch from 29ca712 to 86db250 Compare January 27, 2016 16:11
@cbuescher
Copy link
Member Author

Didn't merge this with master but with feature-suggest-refactoring branch in c00c0fa.

@cbuescher cbuescher closed this Jan 27, 2016
@cbuescher cbuescher removed :Search Refactoring :Search Relevance/Suggesters "Did you mean" and suggestions as you type labels Feb 22, 2016
@cbuescher cbuescher deleted the init-phraseSuggester-refactoring branch March 31, 2016 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants