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

Implemented SphinxAdapter #218

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

m4ikel
Copy link

@m4ikel m4ikel commented Dec 21, 2016

I needed a SphinxClient adapter for my own use but it might be useful for other people, so here we go.

Maikel Doezé added 5 commits December 21, 2016 02:45
Added a new adapter to support searches through SphinxClient
Added Sphinx adapter documentation.
Added comment param to Sphinx docs.
Added missing setCutoff + setMaxMatches into Adapter to control query output.
Total_found is not corresponding with the actual available pages, but with the possible available results. Changed to total.
@m4ikel
Copy link
Author

m4ikel commented Mar 21, 2017

@stof could you check this pull request? It's a ready-to-eat meal ))

Copy link
Collaborator

@sampart sampart left a comment

Choose a reason for hiding this comment

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

Thank you for contributing your work back to the community, @m4ikel! I'm sorry about the delay in this getting reviewed. I've got a few comments about changes I think this needs before we merge it. Thanks in anticipation. Sam

README.md Outdated
@@ -315,6 +315,22 @@ $query->setQuery('search term');
$adapter = new SolariumAdapter($solarium, $query);
```

### SphinxAdapter
To paginate a [Sphinx](http://php.net/manual/en/class.sphinxclient.php) query:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a better page you could link to? The PHP client page doesn't actually say what Sphinx is. Is it http://sphinxsearch.com/?

/*
* This file is part of the Pagerfanta package.
*
* (c) Maikel Doezé <maikel.doeze@marqin.nl>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you remove the copyright message? I know that many of the files have a copyright message relating to Pablo Diez, but for simplicity, we want to move towards one copyright framework for the whole project rather than per-file statements.

class SphinxAdapter implements AdapterInterface
{
private $client;
private $query;
Copy link
Collaborator

Choose a reason for hiding this comment

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

You don't need the extra indent here.

* @param SphinxClient $client A Sphinx client.
* @param $query A Sphinx query.
* @param $index A Sphinx index.
* @param $comment A Sphinx comment.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please could you fix the indentation on these two lines?

$this->client = $client;
$this->query = $query;
$this->index = $index;
$this->comment = $comment;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you tidy the indentation here too, please?

* Constructor.
*
* @param SphinxClient $client A Sphinx client.
* @param $query A Sphinx query.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are @query, $index and $comment all strings? Please could you update the docblock to show this?

/*
* setMaxMatches
*
* @param $maxMatches Controls how much matches searchd will keep in RAM while searching.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you put a variable type in the docblock here too please?

/*
* setCutoff
*
* @param $maxMatches Used for advanced performance control. It tells searchd to forcibly stop search query once cutoff matches have been found and processed.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please could you put a variable type in this docblock too?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, the variable name in the docblock doesn't match the parameter name.

private $index;
private $comment;
private $results;
private $maxMatches = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are you missing a setter for $maxMatches?

$this->comment = $comment;
}

/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

You've got a bit of extra indentation here that you don't need.

@stof
Copy link
Contributor

stof commented Apr 6, 2017

And tests are missing

Removed copyright notice, fixed docblocks added getters and changed readme.
@m4ikel
Copy link
Author

m4ikel commented Sep 7, 2017

@sampart I've implemented your feedback and pushed it this branch. @stof When I have time again I will try to implement unit tests too. So far I've been using this adapter in production.

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

Successfully merging this pull request may close these issues.

3 participants