我一直在使用mysql FTS,但最近切换到sphinx进行测试.
在centos 7上安装了sphinx
Linux production 3.10.0-123.8.1.el7.x86_64 #1 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
的sphinx.conf
source content_src1
{
type = mysql
sql_host = localhost
sql_user =
sql_pass =
sql_db = t_prod2
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT content.record_num, \
content.title, \
content.category, \
content.upload_date, \
content.comments_count, \
content.verified, \
content.uploader, \
content.size \
FROM content WHERE enabled = 1
sql_attr_uint = record_num
sql_attr_string = title
}
index content_index1
{
source = content_src1
path = /var/lib/sphinx/content_index1
morphology = stem_en
min_word_len …Run Code Online (Sandbox Code Playgroud) 我是做bulk inserts在RealTime Index使用PHP和禁用AUTOCOMIT,如
// sphinx connection
$sphinxql = mysqli_connect($sphinxql_host.':'.$sphinxql_port,'','');
//do some other time consuming work
//sphinx start transaction
mysqli_begin_transaction($sphinxql);
//do 50k updates or inserts
// Commit transaction
mysqli_commit($sphinxql);
Run Code Online (Sandbox Code Playgroud)
在我看到的早晨,让剧本一夜之间保持运行
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate
212334 bytes) in
Run Code Online (Sandbox Code Playgroud)
所以当我仔细检查nohup.out文件时,我注意到,这些线条,
PHP Warning: mysqli_query(): MySQL server has gone away in /home/script.php on line 502
Warning: mysqli_query(): MySQL server has gone away in /home/script.php on line 502
Run Code Online (Sandbox Code Playgroud)
这些行之前的内存使用率是正常的,但这些行之后的内存使用量开始增加,并且它击中php mem_limit …
我正在使用Ubuntu 12.04 + PHP + Nginx + MySQL 5.6
我的项目路径是/ usr/share/nginx/www/project1
我成功安装了Sphinx并能够连接完整的API.但我喜欢使用SphinxQL Query Builder.
我不熟悉composer和php命名空间.我在我的机器上安装了作曲家.
我将"SphinxQL-Query-Builder-master"文件夹复制到我的项目根目录.
现在我执行了这个
use Foolz\SphinxQL\SphinxQL;
use Foolz\SphinxQL\Connection;
// create a SphinxQL Connection object to use with SphinxQL
$conn = new Connection();
$conn->setParams(array('host' => 'domain.tld', 'port' => 9306));
$query = SphinxQL::create($conn)->select('column_one', 'colume_two')
->from('index_ancient', 'index_main', 'index_delta')
->match('comment', 'my opinion is superior to yours')
->where('banned', '=', 1);
$result = $query->execute();
Run Code Online (Sandbox Code Playgroud)
这将返回致命错误:找不到类'Foolz\SphinxQL\Connection'
任何人都可以帮我一步一步指导吗?
谢谢!!
我有一个网站,用户可以通过输入关键字来搜索帖子,我正在使用 Sphinx 搜索进行全文搜索,一切都按预期工作。
但是,当我在搜索查询中输入/输入一些特殊字符时,搜索不会完成并引发错误。
例如我搜索的关键字:
hello)
Run Code Online (Sandbox Code Playgroud)
我对 sphinxql 的查询:
SELECT id FROM index1 WHERE MATCH('hello)')
Run Code Online (Sandbox Code Playgroud)
我得到的错误:
index index1: syntax error, unexpected ')' near ')'
Run Code Online (Sandbox Code Playgroud)
我的 php 代码如下所示
<?php
$sphinxql = mysqli_connect($sphinxql_host.':'.$sphinxql_port,'','') or die('ERROR');
$q = urldecode($_GET['q']);
$sphinxql_query = "SELECT id FROM $sphinx_index WHERE MATCH('".$q."') ";
?>
Run Code Online (Sandbox Code Playgroud)
如何转义用户输入并确保查询不会中断并返回结果集?