Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use SphinxSE to call Sphinx in Ubuntu mysql and the Application of Chinese word Segmentation

Shulou Source: shulou.com Published: 2022-06-01 04:34:58 11月01日 Update

Editor to share with you how Ubuntu mysql uses SphinxSE to call Sphinx and the application of Chinese word segmentation. I hope you will get something after reading this article. Let's discuss it together.

1. Using SphinxSE to call Sphinx in Ubuntu mysql

First, create an index special table:

CREATETABLE`sphinx` (`id`int (11) NOTNULL, `weight`int (11) NOTNULL, `query`varchar (255) NOTNULL, `CATALOGID`INTNOTNULL, `EDITUSERID`INTNOTNULL, `HITS`INTNULL, `ADDTIME`INTNOTnull, KEY `Query` (`Query`)) ENGINE=SPHINXDEFAULTCHARSET=utf8CONNECTION='sphinx://localhost:3312/test1'

Test1: the name of the index. After you can find the special indexing table in sphinx.conf, we can use it in Ubuntu mysql, for example, enter it in Ubuntu mysql

SELECTdoc.*FROMdocumentsdocJOINsphinxON (doc.id=sphinx.id) WHEREquery='doc;mode=any'

After running, the result record will show the syntax of the record lines used including the doc string about query, as well as the configuration of sphinx. You can refer to: http://www.sphinxsearch.com/doc.html here is a very detailed introduction, here we only do a brief introduction, hope to play a valuable effect.

2. The application of Ubuntu mysql Chinese word segmentation.

Before applying, let's install apache2 and phpmyadmin so that we can input Chinese for testing.

Apt-getinstallapache2 apt-getinstallphpmyadmin

Visit: http://192.168.2.249/phpmyadmin/ has a familiar interface, ok, installed successfully.

Then we need to change the mysql.default_ tmp/mysql.sock value in / etc/php5/apache2/php.ini to / tmp/mysql.sock so that we can access Ubuntu mysql through the root user (password empty) on http://192.168.2.249/phpmyadmin/.

Generate and use the participle dictionary mmseg-u/root/mmseg-0.7.3/data/unigram.txt will generate the unigram.txt.lib file to copy the file under / usr/local/sphinx/, name it uni.libcpunigram.txt.lib/usr/local/sphinx/uni.lib, modify the sphinx.conf (/ usr/local/sphinx/etc/sphinx.conf) configuration file and add it to the index.

Charset_type=zh_cn.utf-8 charset_dictpath=/usr/local/sphinx/

The configuration then rebuilds the index through / usr/local/sphinx/bin/indexer--config/usr/local/sphinx/etc/sphinx.conf-all (if searchd has been run again, kill it before running. In the next section, we will describe how to load the index while searchd is running). After success, enable index snooping / usr/local/sphinx/bin/searchd--config/usr/local/sphinx/etc/sphinx.conf so that you can test it in phpmyadmin.

SELECTdoc.*FROMdocumentsdocJOINsphinxON (doc.id=sphinx.id) WHEREquery=' Jacky Cheung; after reading this article, I believe you have a certain understanding of "how Ubuntu mysql uses SphinxSE to call Sphinx and the application of Chinese word segmentation". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Index Chinese application run mode file configuration success article dedicated test generate input throw a brick lieutenant general information name dictionary character string Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Redmi Docker Xiaomi macOS