yii2-sphinx icon indicating copy to clipboard operation
yii2-sphinx copied to clipboard

Manticore Search compatibility

Open tom-- opened this issue 5 months ago • 4 comments

Using this client with Manticore Search src/Schema.php fails on line 242 because in Manticore the first field name in the response to SHOW TABLES changed from 'Index' to 'Table'. This is fixed by changing that line to

$indexName = $index['Table'] ?? $index['Index'];

After making that change I ran the unit tests:

  • 3.5.1 works without any errors
  • 2.2.11 i can't run because my system cannot install the old libmysqlclient20 and I can't be bothered setting up a container with an old debian.
  • Manticore 10.1.0 I made a conf file for running the unit tests, which I can contribute if you like (relative to the 3.5.1 config it's just a matter of changing the datadir back to the old path specs).

With Manticore 10.10.1

PHPUnit 6.5.14 by Sebastian Bergmann and contributors.

...FSS.....F.......SS..........................................  63 / 164 ( 38%)
............................................................... 126 / 164 ( 76%)
......................................                          164 / 164 (100%)

Time: 236 ms, Memory: 12.00MB

There were 2 failures:

1) yiiunit\extensions\sphinx\ActiveDataProviderTest::testTotalCountFromMeta
Failed asserting that 1 matches expected 1002.

/home/fsb/yii2-sphinx/tests/ActiveDataProviderTest.php:107
phpvfscomposer:///home/fsb/yii2-sphinx/vendor/phpunit/phpunit/phpunit:52
/home/fsb/yii2-sphinx/vendor/bin/phpunit:118

2) yiiunit\extensions\sphinx\ActiveRecordTest::testFind
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     'id' => '2'
     'author_id' => '2'
     'tag' => '3,4'
+    'title' => 'About dogs'
+    'content' => 'This article is about dogs. Repeated.'
+    'create_date' => '2013-11-15 00:00:00'

/home/fsb/yii2-sphinx/tests/ActiveRecordTest.php:89
phpvfscomposer:///home/fsb/yii2-sphinx/vendor/phpunit/phpunit/phpunit:52
/home/fsb/yii2-sphinx/vendor/bin/phpunit:118

FAILURES!
Tests: 164, Assertions: 878, Failures: 2, Skipped: 4.

I spent some time on failure 1) and could not understand it. As far as I can see the data provider doesn't get the total rows result because the meta response from searchd is empty. The searchd query log shows it is not receiving the SHOW META sql. I tried to understand how come but failed. It has something to do with SQL generation and I found it confusing.

Failure 2) is easy. The result simply has more information than expected and I don't think users would have a problem with that. In other words, this is a failure of the test code. (btw, looks like line 88 of tests/ActiveRecordTest.php is a hack for related purpose.)

Does anyone care?

I considered making a PR but 1) i'm out of practice contributing and made a big mess 2) all i've got is what I wrote above and my manticore-10.1.0.conf file, 3) i don't know how to make the tests run automatically in whatever this travis thing is, i just ran them in my dev repo, 4) i can't do run 2.2.11 tests. 5) who cares? Manticore switched Index -> Table many years ago and it completely broke this client lib. either nobody uses this lib with Manticore or they patched it themselves.

So, what do you want to do?

If we want to fix it and get automatic unit tests running it's probably better for someone who knows that art to do it and I can advise/contribute what I know, most of which is above.

tom-- avatar Jul 08 '25 13:07 tom--

And, btw, Manticore maintains a good PHP client library

https://github.com/manticoresoftware/manticoresearch-php

which in some ways I prefer to yii2-sphinx. But yii2-sphinx offers AR, an active data provider and other APIs apis familiar to Yii 2 Framework users. If it is important to offer these Yii-style apis then it might be better to build them on top of the Manticore PHP client.

tom-- avatar Jul 08 '25 13:07 tom--

Thanks for the contribution, i'll try to implement it over the weekend.

terabytesoftw avatar Jul 08 '25 21:07 terabytesoftw

Thanks for the contribution, i'll try to implement it over the weekend.

Gr8.

To run Manticore, use settings for index { path } and searchd { log | query_log | pid_file | binlog_path } as in tests/data/sphinx2.11.1.conf. Manticore did not adopt the common { datadir } setting that Sphinx later did, as in the 3.5.1 conf.

You only need the indexer and searchd binaries to test. But the manticore apt has 18 .deb dependent packages and installs thousands of files around your system. For my tests I avoided using apt-get install thus:

On the page https://manticoresearch.com/install/ in the Separate packages section, find URLs for the two .deb files suitable for your env: manticore-server-core and manticore-tools. Download those and extract them with dpkg-deb -x. Use the paths to the extracted indexer and searchd binaries in the unit tests.

tom-- avatar Jul 09 '25 14:07 tom--

Nice!

samdark avatar Jul 09 '25 14:07 samdark