-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
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.
@stof could you check this pull request? It's a ready-to-eat meal )) |
There was a problem hiding this 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: |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; | ||
} | ||
|
||
/** |
There was a problem hiding this comment.
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.
And tests are missing |
Removed copyright notice, fixed docblocks added getters and changed readme.
I needed a SphinxClient adapter for my own use but it might be useful for other people, so here we go.