I’m migrating my app from sphinx search to manticore search (sphinx 2.3.x always bugs, and sphinx 3.x cant start on several servers). I used the sphinxapi in php and i’m going to use manticoresearch-php. With sphinx i would just get the document ids like this:
$query = $sphinx->EscapeString($query);
$results = $sphinx->Query(str_replace(’-’, ’ ‘, $query), VCfg::get(‘sphinx_index’));
And then from mysql i just get my columns like this:
$ids = implode(’,’, array_keys($results[‘matches’]));
$this->db->query(’
SELECT ‘.implode(’, ‘, $columns).’
FROM #__video AS v
LEFT JOIN #__channel AS c ON (c.channel_id = v.channel_id)
LEFT JOIN #__user AS u ON (u.user_id = v.user_id AND u.status = 1)
WHERE v.video_id IN (’.$ids.’)
ORDER BY FIELD (v.video_id, ‘.$ids.’)
');
How can i do this with manticoresearch-php. I didnt find an option to get document ids only, it always fetches all fields from the index. I have alot more columns that i need from mysql, which i dont save in the index (it would just use space, i dont use those columns for searching).
is this what you are looking for? Or do you want to avoid iterating through the documents array and are looking for a method which would do it for you and would return the ids list right away?
I wanted to avoid iterating through the documents array (2 times). In the end i decided i will use php mysqli for this. I will benchmark which method is faster once i get some free time. Thank you for helping!
I did a small benchmark and using mysqli is faster (2x). While using manticoresearch-php might be easier to maintain in the long run, using mysqli is important because i have alot of clients that want to run video sites with 1 million entries on a 20$ vps.
When, years ago, I stopped using the Sphinx PHP API, I did so because I got tired of the effort involved in updating the PHP API when I updated the searchd version. In other words, I believe that that using the SQL interface is easier to maintain over search engine version upgrades.