I've tried googling this but I'm not sure if my terminology is wrong or I have the wrong idea on how to use Sphinx.
I need some help with creating and searching a index of a table from a database using something like sphinx. I'm running Ubuntu 14.04 LTS.
My sphinx configuration file looks like this:
source db1
{
sql_host = localhost
sql_user = user1
sql_pass = pswd123
sql_db = db1
sql_port = 3306
type = mysql
sql_query = SELECT * FROM MetaData;
}
index myidx
{
source = mureinome
path = /var/lib/sphinxsearch/data/myidx
docinfo = extern
# Added after suggestion from Mihai
min_stemming_len = 1
min_word_len = 1
dict = keywords
}
indexer
{
mem_limit = 1000M
write_buffer = 50M
}
searchd
{
listen = 9312
listen = 9306:mysql41
pid_file = /var/run/sphinxsearch/searchd.pid
binlog_path = /var/lib/sphinxsearch/data
}
To index the table I run:
root@M4:/var/lib/sphinxsearch# indexer myidx --rotate
Sphinx 2.2.10-id64-release (2c212e0)
Copyright (c) 2001-2015, Andrew Aksyonoff
Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/etc/sphinxsearch/sphinx.conf'...
indexing index 'myidx'...
WARNING: Attribute count is 0: switching to none docinfo
collected 1 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 1 docs, 459 bytes
total 0.005 sec, 80286 bytes/sec, 174.91 docs/sec
total 3 reads, 0.000 sec, 0.6 kb/call avg, 0.0 msec/call avg
total 9 writes, 0.000 sec, 0.6 kb/call avg, 0.0 msec/call avg
rotating indices: successfully sent SIGHUP to searchd (pid=2444).
But when I try to search the index I get an empty result:
SELECT * FROM myidx WHERE MATCH('FC') LIMIT 0,5;
Empty set (0.00 sec)
In MySQL One of the columns in the table looks like this:
mysql> select SampleName from MetaData;
+-----------------+
| SampleName |
+-----------------+
| FCPG1048_S1S2S3 |
+-----------------+
1 row in set (0.00 sec)
Am I indexing the table wrong or am I searching the index wrong? Any help is greatly appreciated.
To enable part word matching need to use min_prefix_len
or min_infix_len
http://sphinxsearch.com/docs/current.html#conf-min-prefix-len
Once done that can use a * in the query. Or use expand_keywords
to effectivly do it automatically.