2017-02-16 91 views
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') 

這個查詢做工精細,但我需要找到一些言辭單調的詞語,例如「母親」必須將產品返還給「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。沒有用。

+0

當你說你改變了'min_index_len'等,你是怎麼改?您無法即時更改大多數索引設置。需要刪除索引,更改配置,然後重建索引(再次插入所有數據)。還要注意''prefix_fields'不適用於RT索引(或更正確的'dict = keywords')。你也有'expand_keywords = 1',所以不應該需要手動添加星星(即第一個例子應該工作) – barryhunter

+0

是的,我的錯誤是,我沒有從文件系統中刪除數據文件。 – gvozd1989

回答

0

我的錯誤是,我不從文件系統,當改變配置刪除數據文件,這是最後的工作配置:

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 
}