php 没有要搜索的已启用的本地索引

iqxoj9l9  于 2022-12-02  发布在  PHP
关注(0)|答案(1)|浏览(114)

我正在尝试设置我的Sphinx 3搜索,我正在使用发行版中的最小默认配置文件。

source src
{
    type            = mysql

    sql_host        = localhost
    sql_user        = a0239779_a*
    sql_pass        = r*
    sql_db          = a0239779_r*
    sql_port        = 3306  # optional, default is 3306
    
    sql_query       = \
        SELECT id, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \
        FROM documents
    
    sql_attr_uint       = id
    sql_attr_timestamp  = date_added

}

index test1
{
    source          = src
    path            = /home/a0239779/sphinx/data/test1
}

index testrt
{
    type            = rt
    rt_mem_limit    = 128M

    path            = /home/a0239779/sphinx/data/testrt
    
    rt_field        = title
    rt_field        = content
    rt_attr_uint    = gid

}

indexer
{
    mem_limit       = 128M
}

searchd
{
    listen          = 9312
    listen          = 9306:mysql41
    log             = /home/a0239779/sphinx/log/searchd.log
    query_log       = /home/a0239779/sphinx/log/query.log
    read_timeout    = 5
    max_children    = 30
    pid_file        = /home/a0239779/sphinx/log/searchd.pid
    seamless_rotate = 1
    preopen_indexes = 1
    unlink_old      = 1
    workers         = threads # for RT to work
    binlog_path     = /home/a0239779/sphinx/data
}

我做了索引,看起来没问题

[a0239779@jarl bin]$ indexer -c /home/a0239779/sphinx/etc/sphinx.conf --all
Sphinx 2.1.5-id64-release (rel21-r4508)
Copyright (c) 2001-2014, Andrew Aksyonoff
Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/home/a0239779/sphinx/etc/sphinx.conf'...
indexing index 'test1'...
WARNING: attribute 'id' not found - IGNORING
collected 4 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4 docs, 227 bytes
total 0.013 sec, 17048 bytes/sec, 300.41 docs/sec
skipping non-plain index 'testrt'...
total 3 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 10 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg

我已经开始找了,好像没问题

[a0239779@jarl bin]$ ./sphinx.sh start
Sphinx 3.1.1 (commit 612d99f)
Copyright (c) 2001-2018, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/home/a0239779/sphinx/etc/sphinx.conf'...
listening on all interfaces, port=9312
listening on all interfaces, port=9306
precaching index 'test1'
WARNING: index 'test1': prealloc: /home/a0239779/sphinx/data/test1.sph is
v.38 (from Sphinx 2.x), binary is v.48; NOT SERVING
precaching index 'testrt'
precached 2 indexes in 0.001 sec

我通过指挥部检查了搜索工作,对吗

[a0239779@jarl bin\]$ search --config /home/a0239779/sphinx/etc/sphinx.conf 'another'
Sphinx 2.1.5-id64-release (rel21-r4508)
Copyright (c) 2001-2014, Andrew Aksyonoff
Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/home/a0239779/sphinx/etc/sphinx.conf'...
index 'test1': query 'another ': returned 1 matches of 1 total in 0.000 sec

displaying matches:

1. document=3, weight=2769, date_added=Sun Oct 11 19:25:17 2020

words:

1. 'another': 1 documents, 2 hits

index 'testrt': search error: failed to open /home/a0239779/sphinx/data/testrt.sph: 
No such file or directory.

然后我想测试直接SQL查询
mysql-h127. 0. 0. 1-P9306数据库管理系统

mysql> SELECT * FROM test1 WHERE MATCH('another');
ERROR 1064 (42000): no enabled local indexes to search

为什么会这样呢?
我还显示了所有表

mysql> SHOW TABLES;
+--------+------+
| index | type |
+--------+------+
| testrt | rt |
+--------+------+
1 row in set (0.00 sec)

为什么只有一个表?我的表“test1”在哪里?
我正在尝试通过PHP测试它

$db = new PDO("mysql:host=127.0.0.1; port=9306; dbname=a0239779_r--; charset=utf8;",
"a0239779_a--", "a0239779_r--");
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);

$stmt = $db->query("SELECT * FROM `test1` WHERE MATCH('another')");
$results = $stmt->fetchAll();
var_dump($results);

未捕获的PDO异常:数据库状态[42000]:语法错误或访问冲突:1064没有要搜索的已启用本地索引

SQL查询是否应该有索引表test1?
如何使用RT表进行SQL查询?

mcvgt66p

mcvgt66p1#

索引器未创建索引,因为在执行索引命令时启动了旧版本2.1.5,但没有可执行文件和配置文件的绝对路径

search --config /home/a0239779/sphinx/etc/sphinx.conf 'another'
Sphinx 2.1.5-id64-release (rel21-r4508)

相关问题