Analyze the usage of coreseek for sphinx
- 2020-06-15 07:59:48
- OfStack
1. Unzip the downloaded file and rename it sphinx or whatever. Then put it in a suitable place, generally under the d root directory.
2. Find the file csft_mysql.conf in D:\sphinx\etc and open it. ue or editplus is recommended. Because Notepad opens with no style. This is because of the file under linux.
3. Make the necessary changes. Because this change is different depending on the table and what you want to fetch, there is no standard, only an instance. My change is like this:
# The source definition
source main
{
type = mysql
sql_host = 192.168.1.250
sql_user = root
sql_pass = 123456
sql_db = db_youxue
sql_port = 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = set SESSION query_cache_type = OFF # I add the
sql_query_pre = replace into sph_counter select 1,max(Fid) from t_store # I add the
sql_query = SELECT Fid, Ftitle, Fcontent, Fprovince,Fexamtitle, UNIX_TIMESTAMP(Fcreatetime) AS Fcreatetime FROM t_store where Fid<=(select Fmaxid from sph_counter where Fid = 1)
#sql_query The first 1 column id For integer
#title , content As a string / Text field, indexed by full text
sql_attr_uint = Fid # from SQL The value read must be an integer
sql_attr_timestamp = Fcreatetime # from SQL The value read must be an integer as a time attribute
sql_query_info = SELECT * FROM t_store WHERE Fid=$id # When the command line queries, the raw data information is read from the database
}
#index define
index main
{
source = main # The corresponding source The name of the
path = var/data/mysql
docinfo = extern
mlock = 0
morphology = none
min_word_len = 1
html_strip = 0
#charset_dictpath = /usr/local/mmseg3/etc/ #BSD , Linux In the environment, / Symbol at the end
charset_dictpath = etc/ #Windows In the environment, / Symbol at the end
charset_type = zh_cn.utf-8
}
# global index define
indexer
{
mem_limit = 128M
}
#searchd The service definition
searchd
{
listen = 9312
read_timeout = 5
max_children = 30
max_matches = 1000
seamless_rotate = 0
preopen_indexes = 0
unlink_old = 1
pid_file = var/log/searchd_mysql.pid
log = var/log/searchd_mysql.log
query_log = var/log/query_mysql.log
}
source deltaMain: main
{
sql_query_pre = set names utf8
sql_query = SELECT Fid, Ftitle, Fcontent, Fprovince,Fexamtitle, UNIX_TIMESTAMP(Fcreatetime) AS Fcreatetime FROM t_store where Fid>(select Fmaxid from sph_counter where Fid=1)
}
index deltaMain: main
{
source = deltaMain
path = var/data/delta
}
This will do the configuration.
4. Find the sphinx directory on the command line. Then type:
bin\indexer -c etc\csft_mysql.conf
Enter. This is to generate a new index.
5. Re-enter:
bin\indexer -c etc\csft_mysql.conf --all
Enter, if I have a lot of data here it's going to take a while. 10, 000 for 20 seconds. Not as fast as the authorities say. Input:
bin\ ES29en-ES30en etc\ csft_ES33en. conf --console enter starts the searchd service. The searchd service can be found in the task manager process at this point. This completes the basic requirements of the query.
6. Input:
bin\searchd -c etc\csft_mysql.conf -a document
Enter, which means to search for all matches that contain document.