Integrating Sphinx to MySQL

后端 未结 1 1395
轻奢々
轻奢々 2021-01-05 14:15

I am trying to use Sphinx full-text search capability for my MySQL server. I have setup a local Sphinx service based on the installation manual and able to do text search.<

相关标签:
1条回答
  • 2021-01-05 14:37

    However I want to integrate Sphinx with my MySQL server, such that all the clients connecting to my sql server can do SphinxQL

    Can't do that. Sphinx (when enabled for sphinxQL) just gives you a server that looks like a mysql one - ie it uses the same communications protocol - mainly so can just reuse mysql client libraries, rather than having to make a new one just for sphinx.

    They are different 'servers'. You connect to a mysql server to run mysql commands; you connect to sphinx server to run sphinxQL commands.

    The application woudl have to connect to each 'server' seperately. Just imagine sphinx was something like postgres, you clearly dont connect to mysql and expect to be able to run postgresql.

    However there is SphinxSE - which is a fake mysql storage engine. You install it into mysql, and you can then create a table using this engine. Then you run mysql queries against this table, under the hood are contacts a running sphinx-server. So to mysql it looks like a table that contains data, this is most useful because can then 'join' this search table with the original data table to get results and the original data in one mysql query.

    The application then doesn't have to connect to sphinx itself. SphinxSE does it for you.

    http://sphinxsearch.com/docs/current.html#sphinxse

    Do I need to convert the database engine from InnoDB to Sphinx?

    No. You keep the original data where it is, using what ever engine you like. Sphinx just provides an 'index' - it doesnt store the original data*. Its not a database as such, just provides for fast quering with its highly optimized indexing.

    Basically you ask sphinx for the unique id's of documents matching a certain query. Then use those ids to lookup the data. SphinxAPI, sphinxSE and sphinxQL are just three different mechanisms of doing that.

    Also, from what it seems, Sphinx can only index one (1) database table per configuration,

    No. A single sphinx instance can host many indexes. And an index can have many sources. So can just create one index per table. Or if you mainly want to search them together, can just create one amalgamated index.

    -- ** Edit to reply to question in comments: **

    When you say that, sphinx can host many indexes, is it relying solely in the sphinx.conf configuration file?

    You would probably define one sphinx index per table. So you would need a source/index pair for each table. (unless you wanted to index all tables in one index, whihch is possible too.

    It cant read the tables itself, and create config file, you have to define each index individually.

    When you say "gives you a server that looks like a mysql one" do you mean like a proxy,

    No. Not a proxy.

    where my MySQL client can connect to this Sphinx port and the client will think that its a MySQL server?

    Basically yes. The client will connect to it the same way it connects to a mysql-server.

     If so, then I can execute both MySQL SQL queries and also SphinxQL at the same connection?

    No. Impossible. Connect to mysql-server, to run mysql queries. Connect to searchd to run sphinxQL queries.

    Two connections, one per server.

    why my MySQL Workbench can't connect to port 9306,

    Don't know. Might be a firewall issue.

    0 讨论(0)
提交回复
热议问题