Home >Backend Development >PHP Tutorial >Yii2 integrates Xunsou to achieve efficient Chinese word segmentation retrieval
Yii2 integrates Xunsou to achieve efficient Chinese word segmentation retrieval. This article mainly introduces the method of Yii2 framework integrating Xunsearch search engine, and analyzes the specific steps and related precautions of Yii2 framework integrating Xunsearch in the form of examples. Friends in need can refer to it. I hope to be helpful.
The details are as follows:
The company has been using the YII2 framework, and then wants to build a Chinese search engine. All I want to do is the Xunsearch project. A previous article mentioned how to install the Xunsearch server. (Refer to "A concise tutorial on how to quickly build full-text search function with PHP under the innodb engine")
xunsearch currently only has the Liunx server and PHP-SDK. But the author does provide an extension for YII2. I suddenly felt so happy.
Originally I was writing a simple function of adding index, updating index and deleting index by using PHP-SDK, but I took into account the situation of multiple projects. That is, one Xunsearch can be shared by multiple projects. All configuration files are placed in the configuration file of each project, and each search database is distinguished according to the configuration file of this project. This was my initial thought, but the point is not what I think, but how I do it. Practice is the last word, and then you encounter the following problems.
See the official http://www.yiiframework.com/extension/yii-xunsearch/#hh4 Here is the target link. I will talk about the installation experience next.
// application components 'components => [ // ... other components ... 'xunsearch' => [ 'class' => 'hightman\xunsearch\Connection', // 此行必须,这里不一定是这写的,可能是hightman.xunsearch.Connection 根据实际项目出发 'iniDirectory' => '@app/config', // 搜索 ini 文件目录,默认:@vendor/hightman/xunsearch/app 'charset' => 'utf-8', // 指定项目使用的默认编码,默认即时 utf-8,可不指定 ], ],
Then, if your The PHP environment is an integrated installation package. You may encounter such a problem
Unexpected character in input: '\' (ASCII=92) state=1
Online Some people said it was a configuration problem in php.ini, and they said that short_open_tag should be changed to On. I thought it made sense at first glance, and then I found out that it was originally On.
Because the YII2 extension uses the namespace effects that are only available in PHP5.3. And my local PHP version is 5.2.6. I said I couldn't calm down. What tortured me all day was actually because the PHP version was too low. . .
That’s all.
Related recommendations:
##yii2 modal pop-up window ActiveForm implements asynchronous form verification of ajax
Yii2 implements rbac permission control
Detailed explanation of the registration and creation methods of components in Yii2
The above is the detailed content of Yii2 integrates Xunsou to achieve efficient Chinese word segmentation retrieval. For more information, please follow other related articles on the PHP Chinese website!