No enabled local indexes to search

235 Views Asked by At

I'm trying to set up my Sphinx3 search, I'm using the minimal default config file from the distribution.

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
}

I did the indexing, it seems allrght

[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

I made a start of the search, it seems allrght

[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

I checked the work of the search through the command, allrght

[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.

Then I want to test direct SQL queries

mysql -h127.0.0.1 -P9306


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

Why is that?

Also I do show all tables


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

Why only 1 table? Where is my table "test1"

I am trying to test it via 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);

Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 no enabled local indexes to search

Should there be an index table test1 for SQL queries?

How can I use the RT table for SQL queries?

2

There are 2 best solutions below

1
Илья Коновалов On

The indexer did not create indexes because the old version 2.1.5 was launched when the command to index without absolute paths to the executable file and config

search --config /home/a0239779/sphinx/etc/sphinx.conf 'another'
Sphinx 2.1.5-id64-release (rel21-r4508)
0
Terry Lin On
failed to open /home/a0239779/sphinx/data/testrt.sph: 
No such file or directory.

You should check if the directory has write permissions (user and group).