Change internal representation of suggesters #16873
Change internal representation of suggesters #16873abeyad merged 6 commits intoelastic:feature-suggest-refactoringfrom
Conversation
There was a problem hiding this comment.
I would prefer to add this test to the existing SuggestBuilderTests and not create a new test class for this. If I understand the existing test in CompletionSuggestSearchIT correctly this is only testing pasting, so it should work, or am I missung something?
|
@abeyad I only had a brief look, left a few minor comments. I like passing the suggesters to the parsing methods as additional argument like in the aggregations parsers. Maybe in a future step we might be able to collaps some of those. I didn't have a close look at the SearchSourceBuilder tests, but would also add a bit more randomization to the suggester setup in createSearchSourceBuilder() (maybe add a few more random suggestions, re-use the randomization from the individual tests if that is already possible?) Also @areek might want to have another look. |
aec2614 to
da6004d
Compare
There was a problem hiding this comment.
@areek @cbuescher One thing I request you both to comment on in particular is adding the NamedWriteable parameter to the registerSuggester method. I don't know if this will cause any issues with registering custom suggester plugins, but adding this parameter is required so that we can register the associated builder with the custom suggester in the namedWriteableRegistry.
There was a problem hiding this comment.
There is a getBuilderPrototype() method each suggester needs to provide which should return the appropriate builder prototype for each suggester. You could register the Suggester itself and then get its class and its builder prototype.
There was a problem hiding this comment.
This is a great idea, I made the change, thanks @cbuescher !
da6004d to
5e768cd
Compare
There was a problem hiding this comment.
I think registering the smoothing models should also go somewhere into SearchModule. Since they are only used in PhraseSuggestionBuilder, I would probably put them alongside the build-in suggestion builders in configureSuggesters()
|
@abeyad I did a round of reviews, left some suggestions. I think you can remove the "WIP" from the title, looks already quiet far to me. After adressing some of the comments I think this only needs to wait for the CompletionSuggestion refactoring and then maybe a final review once all tests pass. |
|
fyi I locally put an @AwaitsFix on CompletionSuggestSearchIT and ContextCompletionSuggestSearchIT to see if any later tests also break and found that in distribution/integ-test-zip there are several rest tests failing with "Suggestion must have name". Maybe we were to eager in enforcing this, maybe we only need to adapt the tests. |
|
@cbuescher I think the tests you are referring to (the |
|
Not sure, to me it looks more general, but maybe you are right. Just wanted to point it out. |
|
Its possible, I started looking at it and showed some of the failures to @areek who thought they were related to the completion suggester only. I figured once that's in, we can iron out any remaining test failures further, because there is also the |
5e768cd to
05369e7
Compare
|
I pushed my latest changes based on @cbuescher comments |
There was a problem hiding this comment.
Nit: you could move the stuff from provideNamedWritableRegistry() here and then in provideNamedWritableRegistry() return the internal NamedWritableRegistry. Maybe less error prone when maintaining the test later to only have one registry around.
|
@abeyad great, left two more minor comments. |
05369e7 to
ec4af5e
Compare
There was a problem hiding this comment.
@cbuescher @areek I added this fromStart method parameter to differentiate, when parsing from x-content, between the situation where the suggest is part of a larger search request, and when the suggest is on its own as part of the suggest API. This may go away later when we merge the implementation of the search with suggest and standalone suggest into one, as @areek suggested before, but what I noticed was in some places, the parsing was failing and always returning back "suggestion name not found", even though there may have been other issues with the parsing. Also, valid JSON was not being parsed correctly by the suggest API. The reason is because in the search with suggest scenario, it has already parsed the starting token for the suggest object, whereas in the suggest API scenario, the starting token has not yet been parsed. In some places, we were adding another parser.nextToken() to account for this, but it wasn't being applied consistently and it was error prone to manage that. I feel having the method itself have a parameter that declares the intentions of the parsing (whether we have already parsed the starting { or not) is more clear and less error prone, but I welcome your thoughts.
There was a problem hiding this comment.
I see the problem but I find adding this extra "control" parameter confusing. I would either make sure that the parser is always on the start token on the caller side (I think in SearchSourceBuilder this is always the case, in tests and in RestSuggestAction we should make sure it is) and otherwise throw an error, or check if parser.currentToken == null inside the SuggestBuilder parse method and advance the token pointer if so. This btw. is what ObjectParser#parse() does by default. I think this would be the best solution.
19c6e30 to
2f628b6
Compare
SuggestBuilder instead of raw bytes.
2f628b6 to
a6662d7
Compare
|
@cbuescher @areek I made some changes based on Areek's feedback. |
|
@abeyad looks good, unfortunately getting some compile errors bc. |
…nto suggester-wiring-refactoring
|
Fixed and pushed changes. On Thu, Mar 10, 2016 at 8:13 AM, Christoph Büscher <notifications@github.com
|
|
@abeyad thanks, still getting test errors (and later some compile issues in reindex module). I'm running |
|
These are the tests (and minor compile thingies) that I found: https://gist.github.com/cbuescher/082435d20ddd279e3db4 |
|
LGTM On Fri, Mar 11, 2016 at 9:52 AM, Christoph Büscher <notifications@github.com
|
Fixing some tests and compile problems in reindex module
|
All tests pass now, LGTM, lets get this in. |
Change internal representation of suggesters
Change internal representation of suggesters to instances of SuggestBuilder instead of raw bytes.