-
Notifications
You must be signed in to change notification settings - Fork 736
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
[Feature] Add support for ES 0.9 Suggest Api #378
Comments
Very interesting. I didn't see this feature so far. So the question is, how we should treat "suggest". Should we handle it the same way as Query, Filter and Facets? If I look at the documentation, it seems like a lot is still coming here (not only Term and Phrase). What do you think? |
From my point of view, it's a lot like the
The only difference is that there is a dedicated API end-point that Elastica should also expose. |
I'm not sure if it is necessary to support the _suggest API endpoint directly. I assume that the following two requests are the same:
Or is there a specific reason you think the endpoint needs to be supported (except for shorter notation)? |
We should have a Request Type at least, or a way to hit only the suggestions for a given Search. You are right, your two examples are the sames but the first one return all the documents too, it's like a match all query. The main advantage of the |
Ok, so what you say is, that the two examples actually do not return the same result. I wasn't aware of that (and should test it ...). So this is different from filters or facets where we don't have this as far as I know. So I agree (in case it is different), that we should offer this capability in Elastica. As Elastica always makes it possible to build your queries yourself, this is already now possible. But there should be a nicer way to do it. Not sure yet, where we should place this _suggest. |
Hi, what happended with this feature? Is there any plan to add it? |
@damienalexandre Any updates here? |
We need to decide how to implement this, then the PR will be pretty easy to do. So, here is what we need:
Let's try to imagine the API: // Simple
$search = new Search($this->getClient());
$search->addIndex($index);
$search->addSuggest(
new TermSuggest("a-name", array("text" => "toto", "term" => array("field" => "body"))
); This example lack for the support of global text (we should be able to set multiple Suggest to the search and only set one "text", is that code a good idea? $search->setSuggestText("toto"); Getting back the results should be as easy as this: $results = $search->search();
$results->getSuggests(); // array('a-name' => ...) I do not have much time to explore the other needs but feel free to complete 😗 |
@damienalexandre I like your approach.
Your imaginary API is powerfull and simple enough for me :) @ruflin what do you think about it? |
As a reminder for myself: #460 |
The main thing I would change is to call it: Elastica\Suggest\Term Same naming convention as for query and filter. Why is it necessary to set the "simple" suggest with text? Is that necessary (yet)? |
Close as pull requests were merged. |
ElasticSearch 0.9 provide a new API for search suggestion.
We can already use it with Elastica but it's not clean IMO:
The suggestions must be fetched from the Response:
We need (this is only a proposal):
Suggests
Search object, holding:TermSuggest
object (or Suggest?) and aPhraseSuggest
with:setText
setField
(mandatory)Query::setSuggest
(like for theFacets
)_suggest
API endpointResultSet::getSuggest
(like for the Facets)The text was updated successfully, but these errors were encountered: