Skip to content
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

Able to configure the method to call on the elasticsearch client #41

Open
bramdevries opened this issue Jun 2, 2016 · 1 comment
Open

Comments

@bramdevries
Copy link
Member

I'm using the suggester API and am using query objects to configure the query it needs to perform. Configuring works but to actually perform a suggest query I have to overwrite the query's run method like this:

 /**
 * Build and execute the query.
 *
 * @return SuggestionsResultParser
 */
public function run()
{
    $query = $this->buildQuery();
    $rawResults = $this->searcher->getClient()->suggest($query);

    // Pass response to the class that will do something with it.
    $resultParser = $this->getResultParser();
    $resultParser->setRawResults($rawResults);

    return $resultParser;
}

A lot of boilerplate to configure one method, it would be nice if this was easily configurable through a method something like:

protected function executeSearch($query) 
{
   return $this->searcher->getClient()->suggest($query);
}
 /**
 * Build and execute the query.
 *
 * @return SuggestionsResultParser
 */
public function run()
{
    $query = $this->buildQuery();
    $rawResults = $this->executeSearch($query);

    // Pass response to the class that will do something with it.
    $resultParser = $this->getResultParser();
    $resultParser->setRawResults($rawResults);

    return $resultParser;
}
@dieterve
Copy link
Contributor

dieterve commented Jul 8, 2016

Interesting, it would make the queries more versatile. I'll look into other contexts the queries could be/need to be re-used.

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

No branches or pull requests

2 participants