Skip to content

Add parsing from xContent to PhraseSuggestionBuilder#16354

Merged
cbuescher merged 1 commit intoelastic:feature-suggest-refactoringfrom
cbuescher:phrase-suggest-fromXContent
Feb 8, 2016
Merged

Add parsing from xContent to PhraseSuggestionBuilder#16354
cbuescher merged 1 commit intoelastic:feature-suggest-refactoringfrom
cbuescher:phrase-suggest-fromXContent

Conversation

@cbuescher
Copy link
Copy Markdown
Member

This adds parsing from xContent to PhraseSuggestionBuilder and changes properties of PhraseSuggestionBuilder to using default values form PhraseSuggestionContext where possible. Also adding access to the global Suggesters via QueryParseContext so we can retrieve the right prototype for parsing the suggestions.

@cbuescher cbuescher added review WIP :Search Relevance/Suggesters "Did you mean" and suggestions as you type labels Feb 1, 2016
@cbuescher cbuescher force-pushed the phrase-suggest-fromXContent branch 2 times, most recently from 12bcf82 to c66b050 Compare February 2, 2016 19:31
@cbuescher cbuescher removed the WIP label Feb 2, 2016
@cbuescher cbuescher force-pushed the phrase-suggest-fromXContent branch 4 times, most recently from 2bfd196 to de5a7dd Compare February 3, 2016 11:13
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure we should add suggesters to this class as it means that anywhere we need to use queries (percolator, aggs, etc.) we need to have suggesters too. I think the suggesters should have their own registry class instead

@colings86
Copy link
Copy Markdown
Contributor

@cbuescher I am concerned about this change making suggesters required everywhere we have queries. Queries are used a lot outside of the Search API and I think it will make other modules (e.g. percolator and aggs) difficult to maintain if they need to pass in suggesters when they don't use them. Personally I think the suggester should have a separate registry like the Aggregations do.

@cbuescher
Copy link
Copy Markdown
Member Author

@colings86 thanks, I will take a look at alternatives, Suggesters already is the central registry, I only need a way to access it from the SuggestionBuilder fromXContent method. Maybe directly adding it to the context there would be an option. Any other ideas welcome.

@javanna
Copy link
Copy Markdown
Contributor

javanna commented Feb 3, 2016

Colin has a good point, would it be possible to treat Suggesters as the registry and instead of adding it to the existing IndicesQueriesRegistry, inject that directly to the parse context? That said the naming is a bit off at the moment, I am not clear on whether QueryParseContext will become SearchParseContext at some point .

@cbuescher cbuescher force-pushed the phrase-suggest-fromXContent branch 3 times, most recently from ce2d247 to ebc36e0 Compare February 3, 2016 15:48
@cbuescher
Copy link
Copy Markdown
Member Author

@colings86 @javanna thanks for the comments, I tried to solve the suggestion builder lookup differently now. The lookup is needed in the common parsing code for fields all SuggestionBuilder share, so initially I put it in the abstract superclass, but by putting it into SuggestParseElement it can directly use the registry that is already wired there. The downside is, we don't have the parsing code in the builder, but thats also not true for the queries. Also the duplicated code we temporarily have in SuggestParseElement will go away after the complete refactoring (also we don't need to call it SuggestParseElement then).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

At this point, it is still possible that the suggestionBuilder could be null, so it would be better to have a check here to throw an exception if suggestionBuilder is null here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good point, added that check

@cbuescher cbuescher force-pushed the phrase-suggest-fromXContent branch 6 times, most recently from d979e36 to 508ca0a Compare February 4, 2016 18:20
@cbuescher
Copy link
Copy Markdown
Member Author

I went a step back and optionally added the suggesters registry I need for parsing to the QueryParseContext directly. That way, when we need it can be add it (e.g. in SearchService when starting the whole parsing chain) and its not part of IndicesQueriesRegistry.

@cbuescher cbuescher force-pushed the phrase-suggest-fromXContent branch 3 times, most recently from c97f39f to 211e64b Compare February 5, 2016 16:08
@cbuescher cbuescher force-pushed the phrase-suggest-fromXContent branch 2 times, most recently from c53640c to e5f3248 Compare February 8, 2016 09:30
@colings86
Copy link
Copy Markdown
Contributor

LGTM

For the ongoing search refactoring (elastic#10217) the PhraseSuggestionBuilder
gets a way of parsing from xContent that will eventually replace the
current SuggestParseElement. This PR adds the fromXContent method
to the PhraseSuggestionBuilder and also adds parsing code for the
common suggestion parameters to SuggestionBuilder.

Also adding links from the Suggester implementations registeres in the
Suggesters registry to the corresponding prototype that is going to
be used for parsing once the refactoring is done and we switch from
parsing on shard to parsing on coordinating node.
@cbuescher cbuescher force-pushed the phrase-suggest-fromXContent branch from e5f3248 to 2ae6420 Compare February 8, 2016 11:32
cbuescher added a commit that referenced this pull request Feb 8, 2016
This adds parsing from xContent to PhraseSuggestionBuilder and changes properties of PhraseSuggestionBuilder to using default values form PhraseSuggestionContext where possible.
@cbuescher cbuescher merged commit c27408b into elastic:feature-suggest-refactoring Feb 8, 2016
@cbuescher cbuescher deleted the phrase-suggest-fromXContent branch March 31, 2016 09:26
@clintongormley clintongormley added :Search/Search Search-related issues that do not fall into other categories and removed :Search Refactoring labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>non-issue :Search Relevance/Suggesters "Did you mean" and suggestions as you type :Search/Search Search-related issues that do not fall into other categories v5.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants