2015-10-15 151 views
0

我試過用google搜索這個,但我不確定我的術語是錯誤的還是我對如何使用獅身人面像有錯誤的想法。使用獅身人面像來索引MySQL表

我需要一些幫助,使用sphinx之類的東西來創建和搜索數據庫中表的索引。我正在運行Ubuntu 14.04 LTS。

我的獅身人面像的配置文件看起來像這樣:

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 
} 

要索引的表我運行:

[email protected]:/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). 

但是,當我嘗試搜索索引我得到一個空的結果:

SELECT * FROM myidx WHERE MATCH('FC') LIMIT 0,5; 
Empty set (0.00 sec) 

在MySQL中表中的一列是這樣的:

mysql> select SampleName from MetaData; 
+-----------------+ 
| SampleName  | 
+-----------------+ 
| FCPG1048_S1S2S3 | 
+-----------------+ 
1 row in set (0.00 sec) 

我是索引表的錯誤還是索引我索引錯了?任何幫助是極大的讚賞。

+0

對Sphinx不太瞭解,但在Mysql做FULLTEXT搜索時,有一個最小字長,請參見'配置最小和最大字長度'一節http://dev.mysql.com/doc/refman/5.6 /en/fulltext-fine-tuning.html我不知道這是如何轉化爲獅身人面像。只需用更長的單詞進行搜索即可測試 – Mihai

+0

現在,您可以這麼說了!搜索整個字符串的作品。 –

+0

還要注意停用詞表,被忽略的詞很常見https://dev.mysql.com/doc/refman/5.6/en/fulltext-stopwords.html – Mihai

回答