Skip to content

Implemented SphinxAdapter#218

Open
m4ikel wants to merge 8 commits into
whiteoctober:masterfrom
m4ikel:master
Open

Implemented SphinxAdapter#218
m4ikel wants to merge 8 commits into
whiteoctober:masterfrom
m4ikel:master

Conversation

@m4ikel

@m4ikel m4ikel commented Dec 21, 2016

Copy link
Copy Markdown

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

m4ikel commented Mar 21, 2017

Copy link
Copy Markdown
Author

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

@sampart sampart left a comment

Copy link
Copy Markdown
Collaborator

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

Comment thread README.md Outdated
```

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

stof commented Apr 6, 2017

Copy link
Copy Markdown
Contributor

And tests are missing

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

m4ikel commented Sep 7, 2017

Copy link
Copy Markdown
Author

@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