ripaclub / sphinxsearch

Sphinx Search library provides SphinxQL indexing and searching features
BSD 2-Clause "Simplified" License
62 stars 10 forks source link

Fatal error: Call to undefined method #49

Open Doopin opened 7 years ago

Doopin commented 7 years ago

I have just downloaded this module and I installed it. But I can work with it because of this fatal error in the screenshot. I actually use Zend 2.4.9. What have I missed please?

Here is my code use SphinxSearch\Search; use SphinxSearch\Db\Sql\Predicate\Match;

$search = new Search($adapter); $rowset = $search->search('foo', new Match('?', 'ipsum dolor'));

echo 'Founds row:' . PHP_EOL; foreach ($rowset as $row) { echo $row['id'] . PHP_EOL; }

op

leogr commented 7 years ago

Which PHP version are you using?

Doopin commented 7 years ago

I use PHP 5.6

leogr commented 7 years ago

It seems an issue related to the specific zend-db version, we can't reproduce currently. We need further investigation.

Could you try your example with another version?

Or could you provide us a full reproducible example of the issue (i.e. source code, composer.json etc..), please?

Thanks in advance.

Doopin commented 7 years ago

It seems this processWithinGroupOrder() method has been removed from SelectDecorator class in Zend Framework 2.4.9 I can't find it in SelectDecorator nor Select and AbstractPreparableSql and AbstractSql classes

However I found this processWithinGroupOrder() method in SphinxSearch\Db\Sql\Select.

Here is my sample code `<?php namespace AppSearch\Controller;

use App\Controller\AppAbstractActionController;

use SphinxSearch\Search; use SphinxSearch\Db\Sql\Predicate\Match;

class IndexController extends AppAbstractActionController {

public function indexAction() {
    $isIndexPage = false;

    $search = new Search($this->getDbAdapter());
    $rowset = $search->search('doopins', new Match('?', 'ipsum dolor'));

    echo 'Founds row:' . PHP_EOL;
    foreach ($rowset as $row) {
        echo $row['id'] . PHP_EOL;
    }

    \Zend\Debug\Debug::dump($rowset); exit;

    return [
        'isIndexPage' => $isIndexPage
    ];
}

}`

leogr commented 7 years ago

Could you attach your composer.json too?

I suppose you're using the zend-db 2.4.8 (because 2.4.9 is the zend framework version, but the zend-db 2.4.9 does not exist). Actually, process* methods are called by zend-db itself (composing the method name in Zend\Db\Sql\AbstractSql, so I'm not sure if the issue is within the zend-db itself OR is an incompatibility with our library.

Doopin commented 7 years ago

Sure! The attached file is the composer.json file renamed to composer.txt

composer.txt

Doopin commented 7 years ago

However if you need more infos, you can have them here on Github in Zend framework repository. Due to a bug in Version 2.2.3 in the past I have downloaded manually the 2.4.9 release zip file and replace my old library folder. So you can go on ZF2 repository the release 2.4.9 to better explore Classes

DSCmattb commented 7 years ago

This is also an issue for me.. Using PHP 7.0.18 with any version of zend 2.4

leogr commented 7 years ago

I closed the issue because I had thought it was resolved, sorry.

Could you provide us more detail? I need some some code to reproduce the issue (provide composer.json and composer.lock too, please), then I'll work on it ASAP.

DSCmattb commented 7 years ago

No problems mate, This is the received error:

http://puu.sh/w7xPB/dacc6e7e92.png

Attached is the files requested

composer.txt composer_lock.txt

The following code is used:

$this->getSphinx()->search('upload', new Match('?', '123'));

public function getSphinx() { if (!$this->sphinx) { $sm = $this->getServiceLocator()->get('Config'); $adapter = new \Zend\Db\Adapter\Adapter($sm["sphinxql"]); $this->sphinx = new Search($adapter); } return $this->sphinx; } Apologises for the weird formatting that github places on the code

leogr commented 7 years ago

@DSCmattb I see you used \Zend\Db\Adapter\Adapter directly, but this library cannot work in that way. This library requires a custom configuration for Zend\Db\Adapter\Adapater that's provided by the included adapter service factory (config documentation here).

Could you try your code with our service factory instead of $adapter = new \Zend\Db\Adapter\Adapter($sm["sphinxql"]) and then let me a feedback?

Thanks in advance!

DSCmattb commented 7 years ago

Can agree, defining it as the documentation works perfectly, sorry for that 👍

leogr commented 7 years ago

@DSCmattb no problem, may be we need to improve docs in order to make the service factory requirement more clear 👍

I'll do that prior to close this issue.

Finally, I'd like to ask to @Doopin if the issue could be marked as solved, isn't it?

Doopin commented 7 years ago

@leogr we can close this issue. Due to a deadline for my application, I had to switch to another search engine solution and it doesn't require this module anymore. I'm sorry but I can't test any of above solutions since sphinx has been removed from my workspace. Thank you.

leogr commented 7 years ago

Ok, no problem! Thank you for your feedback.