I have several databases for sphinx query. each database uses sphinx to create different indexes.
But the query goes wrong.
For example, I want to query the required content from database.
How can I specify the index of the database to be queried?
This is my coreseek configuration
# Music source definition source music {type = mysql SQL _host = localhost SQL _user = root SQL _pass = SQL _db = music SQL _port = 3306 SQL _query_pre = set names utf8 SQL _query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM allmusic SQL _query = SELECT id, 'name', 'Singer' FROM allmusic WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1) # The id of the first column of SQL _query must be an integer # name and singer are used as string/text fields. when the full-text index SQL _query_info_pre = SET NAMES utf8 # command line queries, set the correct character set SQL _query_info = SELECT id, 'name', 'Singer' FROM allmusic WHERE id = $ id # When querying through the command line, read original data from the database} # music incremental Index source mdelta: music {SQL _query_pre = SET NAMES utf8 # sel_query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM allmusicsql_query = SELECT id, 'name', 'Singer' FROM allmusic WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1 )} # novel source definition source novel {type = mysqlsql_host = localhostsql_user = rootsql_pass = SQL _db = novelsql_port = records = SET NAMES utf8sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM novelsql_query = SELECT id, 'name', 'author', 'is _ small' FROM novel WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1) # The id of the first column of SQL _query must be an integer # name and singer are used as string/text fields, and the full-text index SQL _attr_uint = is_smallsql_query_info_pre = SET NAMES utf8 # When querying through the command line, set the correct character set SQL _query_info = SELECT id, 'name', 'IMG ', 'Des', 'content ', 'is _ small' FROM novel FROM allmusic WHERE id = $ id # When querying through the command line, read the original data FROM the database} source ndelta: novel {SQL _query_pre = SET NAMES utf8 # sel_query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM novelsql_query = SELECT id, 'name', 'author ', 'is _ small' FROM novel WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1) SQL _attr_uint = is_small} # index defines index music {source = music # corresponding source name path = E:/sphsf-/ music/# change it to the actual absolute path, for example: /usr/local/coreseek/var /... docinfo = extern mlock = 0 morphology = none html_strip = 0 # charset_dictpath =/usr/local/mmseg3/etc/# BSD, set in Linux environment,/character ending with charset_dictpath = C: /usr/local/coreseek/etc/# In Windows, it is best to give an absolute path, for example, C:/usr/local/coreseek/etc /... charset_type = zh_cn.utf-8 min_prefix_len = 0 min_infix_len = 0 min_word_len = 2 ngram_len = 0 ngram_chars = U + 4E00 .. U + 9FBF, U + 3400 .. U + 4DBF, U + 20000 .. U + 2A6DF, U + f900 .. U + FAFF, \ U + 2F800 .. U + 2FA1F, U + 2E80 .. U + 2EFF, U + 2F00 .. U + 2FDF, U + 3100 .. U + 312F, U + 31A0 .. U + 31BF, \ U + 3040 .. U + 309F, U + 30A0 .. U + 30FF, U + 31F0 .. U + 31FF, U + ac00 .. U + D7AF, U + 1100 .. U + 11FF, \ U + 3130 .. U + 318F, U + a000 .. U + A48F, U + a490 .. U + A4CF} index mdelta: music {source = deltapath = E:/sphsf-/ music/delta} # index defines index novel {source = novel # corresponding source name path = E: /sphinx/novel/# change it to the actual absolute path, for example,/usr/local/coreseek/var /... docinfo = extern mlock = 0 morphology = none html_strip = 0 # charset_dictpath =/usr/local/mmseg3/etc/# BSD, set in Linux environment,/character ending with charset_dictpath = C: /usr/local/coreseek/etc/# In Windows, it is best to give an absolute path, for example, C:/usr/local/coreseek/etc /... charset_type = zh_cn.utf-8 min_prefix_len = 0 min_infix_len = 0 min_word_len = 2 ngram_len = 0 ngram_chars = U + 4E00 .. U + 9FBF, U + 3400 .. U + 4DBF, U + 20000 .. U + 2A6DF, U + f900 .. U + FAFF, \ U + 2F800 .. U + 2FA1F, U + 2E80 .. U + 2EFF, U + 2F00 .. U + 2FDF, U + 3100 .. U + 312F, U + 31A0 .. U + 31BF, \ U + 3040 .. U + 309F, U + 30A0 .. U + 30FF, U + 31F0 .. U + 31FF, U + ac00 .. U + D7AF, U + 1100 .. U + 11FF, \ U + 3130 .. U + 318F, U + a000 .. U + A48F, U + a490 .. U + A4CF} index ndelta: novel {source = ndeltapath = E: /sphenders/novel/delta} # global index definition indexer {mem_limit = 128 M} # searchd 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 = E: /var/log/searchd_mysql.pid # change it to the actual absolute path, for example,/usr/local/coreseek/var /... log = E:/var/log/searchd_mysql.log # change it to the actual absolute path, for example,/usr/local/coreseek/var /... query_log = E:/var/log/query_mysql.log # change it to the actual absolute path, for example,/usr/local/coreseek/var /... binlog_path = # Disable binlog compat_sphinxql_magics = 0}
Reply to discussion (solution)
Could you give me some advice?
Public array SphinxClient: query (string $ query [, string $ index = "*" [, string $ comment = ""])
Index
Index Name (multiple index names can be separated by commas or "*" indicates all indexes ).
I have several databases, and each database uses sphinx to create different indexes.
But the query goes wrong.
For example, I want to query the required content from database.
How can I specify the index of the database to be queried?
This is my coreseek configuration
# Music source definition source music {type = mysql SQL _host = localhost SQL _user = root SQL _pass = SQL _db = music SQL _port = 3306 SQL _query_pre = set names utf8 SQL _query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM allmusic SQL _query = SELECT id, 'name', 'Singer' FROM allmusic WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1) # The id of the first column of SQL _query must be an integer # name and singer are used as string/text fields. when the full-text index SQL _query_info_pre = SET NAMES utf8 # command line queries, set the correct character set SQL _query_info = SELECT id, 'name', 'Singer' FROM allmusic WHERE id = $ id # When querying through the command line, read original data from the database} # music incremental Index source mdelta: music {SQL _query_pre = SET NAMES utf8 # sel_query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM allmusicsql_query = SELECT id, 'name', 'Singer' FROM allmusic WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1 )} # novel source definition source novel {type = mysqlsql_host = localhostsql_user = rootsql_pass = SQL _db = novelsql_port = records = SET NAMES utf8sql_query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM novelsql_query = SELECT id, 'name', 'author', 'is _ small' FROM novel WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1) # The id of the first column of SQL _query must be an integer # name and singer are used as string/text fields, and the full-text index SQL _attr_uint = is_smallsql_query_info_pre = SET NAMES utf8 # When querying through the command line, set the correct character set SQL _query_info = SELECT id, 'name', 'IMG ', 'Des', 'content ', 'is _ small' FROM novel FROM allmusic WHERE id = $ id # When querying through the command line, read the original data FROM the database} source ndelta: novel {SQL _query_pre = SET NAMES utf8 # sel_query_pre = REPLACE INTO sph_counter SELECT 1, MAX (id) FROM novelsql_query = SELECT id, 'name', 'author ', 'is _ small' FROM novel WHERE id <= (SELECT max_id FROM sph_counter WHERE counter_id = 1) SQL _attr_uint = is_small} # index defines index music {source = music # corresponding source name path = E:/sphsf-/ music/# change it to the actual absolute path, for example: /usr/local/coreseek/var /... docinfo = extern mlock = 0 morphology = none html_strip = 0 # charset_dictpath =/usr/local/mmseg3/etc/# BSD, set in Linux environment,/character ending with charset_dictpath = C: /usr/local/coreseek/etc/# In Windows, it is best to give an absolute path, for example, C:/usr/local/coreseek/etc /... charset_type = zh_cn.utf-8 min_prefix_len = 0 min_infix_len = 0 min_word_len = 2 ngram_len = 0 ngram_chars = U + 4E00 .. U + 9FBF, U + 3400 .. U + 4DBF, U + 20000 .. U + 2A6DF, U + f900 .. U + FAFF, \ U + 2F800 .. U + 2FA1F, U + 2E80 .. U + 2EFF, U + 2F00 .. U + 2FDF, U + 3100 .. U + 312F, U + 31A0 .. U + 31BF, \ U + 3040 .. U + 309F, U + 30A0 .. U + 30FF, U + 31F0 .. U + 31FF, U + ac00 .. U + D7AF, U + 1100 .. U + 11FF, \ U + 3130 .. U + 318F, U + a000 .. U + A48F, U + a490 .. U + A4CF} index mdelta: music {source = deltapath = E:/sphsf-/ music/delta} # index defines index novel {source = novel # corresponding source name path = E: /sphinx/novel/# change it to the actual absolute path, for example,/usr/local/coreseek/var /... docinfo = extern mlock = 0 morphology = none html_strip = 0 # charset_dictpath =/usr/local/mmseg3/etc/# BSD, set in Linux environment,/character ending with charset_dictpath = C: /usr/local/coreseek/etc/# In Windows, it is best to give an absolute path, for example, C:/usr/local/coreseek/etc /... charset_type = zh_cn.utf-8 min_prefix_len = 0 min_infix_len = 0 min_word_len = 2 ngram_len = 0 ngram_chars = U + 4E00 .. U + 9FBF, U + 3400 .. U + 4DBF, U + 20000 .. U + 2A6DF, U + f900 .. U + FAFF, \ U + 2F800 .. U + 2FA1F, U + 2E80 .. U + 2EFF, U + 2F00 .. U + 2FDF, U + 3100 .. U + 312F, U + 31A0 .. U + 31BF, \ U + 3040 .. U + 309F, U + 30A0 .. U + 30FF, U + 31F0 .. U + 31FF, U + ac00 .. U + D7AF, U + 1100 .. U + 11FF, \ U + 3130 .. U + 318F, U + a000 .. U + A48F, U + a490 .. U + A4CF} index ndelta: novel {source = ndeltapath = E: /sphenders/novel/delta} # global index definition indexer {mem_limit = 128 M} # searchd 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 = E: /var/log/searchd_mysql.pid # change it to the actual absolute path, for example,/usr/local/coreseek/var /... log = E:/var/log/searchd_mysql.log # change it to the actual absolute path, for example,/usr/local/coreseek/var /... query_log = E:/var/log/query_mysql.log # change it to the actual absolute path, for example,/usr/local/coreseek/var /... binlog_path = # Disable binlog compat_sphinxql_magics = 0}
Search by index name. it is not a specified database. sphsf-search has nothing to do with the database.
$ Cl = new SphinxClient (); $ cl-> SetServer ('localhost', '123'); $ res = $ cl-> Query ('I ', "novel ");
Http://docs.php.net/manual/zh/sphinxclient.query.php