简体   繁体   中英

INSERT through SphinxSE

I defined a real-time index (RT index) on SphinxSearch 2.1.8:

index rt
{
    type = rt
    path = /var/lib/sphinxsearch/data/rt
    rt_field = url
}

Then I declared a table in MariaDB 10.0.11 using SPHINX Storage Engine:

CREATE TABLE `rt` (
  `id` bigint(20) unsigned NOT NULL,
  `weight` int(11) NOT NULL,
  `query` text NOT NULL,
  `url` varchar(255) DEFAULT NULL,
  KEY `query` (`query`(1024))
) ENGINE=SPHINX DEFAULT CHARSET=utf8 CONNECTION='sphinx://127.0.0.1:9312/rt';

Is it possible to INSERT data into my RT index through the SphinxSE table ?

When I try to insert, I have this error:

MariaDB [mydb]> INSERT INTO rt(id, url) VALUES (1, 'http://www.stackoverflow.com');
ERROR 1031 (HY000): Storage engine SPHINX of the table `mydb`.`rt` doesn't have this option

According to this comment from MariaDB KB it may be possible to INSERT/UPDATE/DELETE a rt index through SphinxSE, but I wonder how...

While in theory it's now possible to have it proxy INSERTs, DELETEs and other writes to Sphinx, it was never initially designed for this, so that change could be cumbersome.

That comment is says it theory possible to modify the source code of the SphinxSE engine, to enable such updates. Basically it will instead make a SphinxQL connect to sphinx, and issue appropriate commands.

But as noted it wasnt designed for that (for example it takes a SphinxAPI port in the table definition - so would need to find another way to tell the engine the SphinxQL port to use) - it will be kind of difficult to do.

... so not possible now. But could be possible if someone wrote the code to do so.

Probably much easier to modify your application to talk SphinxQL directly to Sphinx.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM