这是我的sphinx搜索配置(sphinxsearch_0.9.9-6_amd64):
index FULL
{
charset_type = utf-8
source = FULL
path = /var/sphinx/data/Full
docinfo = extern
mlock = 0
min_stemming_len = 1
min_prefix_len = 1
min_word_len = 1
html_strip = 1
index_exact_words = 1
}
searchd
{
listen = 192.168.2.3
log = /var/log/sphinxsearch/searchd.log
query_log = /var/log/sphinxsearch/query.log
read_timeout = 3
client_timeout = 60
max_children = 30
pid_file = /var/run/searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 0
unlink_old = 1
mva_updates_pool = 1M
max_packet_size = 8M
max_filters = 256
max_filter_values = 4096
}
我使用php作为客户端
$sphinx_client->SetServer('localhost', 9312);
$sphinx_client->SetConnectTimeout(1);
$sphinx_client->SetArrayResult(true);
$sphinx_client->setRankingMode(SPH_RANK_WORDCOUNT);
$sphinx_client->SetMatchMode(SPH_MATCH_EXTENDED2);
if ($mode == 'all') {
$sphinx_client->SetSortMode(SPH_SORT_RELEVANCE, 'category');
} else {
$sphinx_client->setFilter('category', array($this->_filter_category), FALSE);
}
$sphinx_client->SetLimits(0, $this->_limit);
$results = $sphinx_client->Query('"^'.$query.'$"', 'FULL');
例如我在索引中有这些名字: 亚历克斯 阿伦 乔治 4. A 5. G
:::当我尝试搜索简单的1字符串“A”时,我得到Alen / Alex / A等等。
如何根据字符串长度进行搜索,以便我可以按正确的顺序显示它们,如: A / Alen / Alex ......
我也得到“警告:索引'满':没有形态,index_exact_words = 1无效,忽略”
最好的问候
答案 0 :(得分:1)
使用序数字段(str2ordinal),进行常规搜索,但修改排序模式:切换到扩展模式并使用$ sphinx_client-> SetSortMode(SPH_SORT_EXTENDED,'@ weight desc,myordinal asc)等组合“);