0

我创建了实时索引:

index berni_filter2
{
    rt_mem_limit    = 512M
    type            = rt
    path            = /var/lib/sphinxsearch/data/berni_filter

    rt_attr_uint    = product_id
    rt_attr_uint    = store_id
    rt_field        = product_name
    rt_attr_json    = attributes

    prefix_fields   = product_name
    expand_keywords = 1
    min_infix_len   = 2
    dict            = keywords
}

然后我尝试通过 SphinxQL 按产品名称字段获取数据:

SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('@product_name mothercare')

此查询工作正常,但我需要找到部分单词,例如“mother”必须返回带有“mothercare”的产品。我试过了:

SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('@product_name mother')
SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('@product_name mother*')
SELECT product_id FROM berni_filter2 WHERE store_id = 0 AND MATCH ('@product_name *mother*')

我尝试将 min_infix_len 更改为 min_prefix_len。没有任何工作。

4

2 回答 2

1

我的错误是,我没有从文件系统中删除数据文件,当更改配置时,这是最终的工作配置:

index berni_filter
{
    rt_mem_limit    = 512M
    type            = rt
    path            = /var/lib/sphinxsearch/data/berni_filter

    rt_attr_uint    = product_id
    rt_attr_uint    = store_id
    rt_field        = product_name
    rt_attr_json    = attributes

    index_exact_words = 1
    expand_keywords   = 1
    min_prefix_len    = 3
    min_word_len      = 2

    morphology        = stem_enru
    dict              = keywords
}
于 2017-02-18T14:45:43.687 回答
0

我遇到了同样的问题。删除索引文件对我也有帮助。在删除之前,我停止了 searchd 服务,然后重新启动它。

于 2021-03-04T16:31:02.997 回答