Как искать слова в сфинксе ?
conf:
source base {
type = mysql
sql_host = 0.0.0.0
sql_user = user
sql_pass = pass
sql_db = base
sql_port = 3306 # optional, default is 3306
sql_query_pre = SET NAMES utf8
}
source src_videos: base {
sql_range_step = 1000
sql_query_range = SELECT MIN(id), MAX(id) FROM table
sql_query = \
SELECT title, description, tags, UNIX_TIMESTAMP(date) as date, остальные поля FROM table WHERE id BETWEEN $start AND $end
sql_attr_string = title
sql_attr_string = description
sql_attr_string = tags
sql_attr_timestamp = date
}
index table {
source = src_videos
path = C:/sphinx/data/table/data_index
morphology = stem_enru
dict = keywords
index_exact_words = 1
expand_keywords = 1
min_word_len = 1
min_prefix_len = 3
}
indexer {
mem_limit = 200M
}
searchd {
listen = 9312
listen = 127.0.0.1:9306:mysql41
log = C:/sphinx/log/searchd.log
query_log = C:/sphinx/log/query.log
read_timeout = 5
max_children = 30
pid_file = C:/sphinx/log/searchd.pid
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = C:/sphinx/data
}
PHP FILE:
$pdo = new PDO('mysql:host=127.0.0.1;port=9306');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->query("SELECT * FROM table WHERE MATCH('фраза поиска или одно слово')");
$results = $stmt->fetchAll();
var_dump($results);
При изменении MATCH выводит все подряд - первые по умолчанию:
$stmt = $pdo->query("SELECT * FROM table WHERE MATCH('')");
нет разницы в слове - языке.