-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Enable serialization and parsing from xContent for SmoothingModels #16130
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
Conversation
b13a5cb
to
ce9583c
Compare
PhraseSuggestionBuilder uses three smoothing models internally. In order to enable proper serialization / parsing from xContent to the phrase suggester later, this change starts by making the smoothing models writable, adding hashCode/equals and fromXContent.
} | ||
|
||
|
||
public static abstract class SmoothingModel<SM extends SmoothingModel<?>> implements NamedWriteable<SM>, ToXContent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why we need to add the type parameter to SmoothingModel
, I have taken a stab at removing it here. IMO, a non-generic SmoothingModel
is simpler. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm absolutely okay to remove it. I think I just added it because we used this for the abstract query builder and some other elements in past refactorings to avoid some casting, but I'm also glad to simlify it here. Will change this.
778c84c
to
b81be16
Compare
@areek thanks for the review, I removed the type parameter from SmoothingModel, also added an aditional buildWordScorerFactory() method that we will need later in the Phrase suggesters build method. Can you take another look if this now look okay to you? |
0753398
to
920c080
Compare
XContentParser parser = parseContext.parser(); | ||
XContentParser.Token token; | ||
String fieldName = null; | ||
final double[] lambdas = new double[3]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: would be nice if these were explicit variables, e.g. trigramLambdaValue
, bigramLambdaValue
and unigramLambdaValue
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, pure lazyness copied over from current PhraseSuggestParser. Will change that.
@cbuescher this looks great, LGTM! I added a minor style comment |
Adds a method that emits a WordScorerFactory to all of the three SmoothingModel implementatins that will be needed when we switch to parsing the PhraseSuggestion on the coordinating node and need to delay creating the WordScorer on the shards.
920c080
to
aefdee1
Compare
Enable Writeable serialization and parsing from xContent for SmoothingModels
PhraseSuggestionBuilder uses three smoothing models internally. In order to enable proper serialization / parsing from xContent to the phrase suggester for the search builder refactoring, this change starts by making the smoothing models writable, adding hashCode/equals and fromXContent.