0

I have created realtime index:

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
}

Then I trying to get data by product name field over SphinxQL:

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

This query work fine, but I need to find partically words, for example "mother" must return products with "mothercare". I have tried:

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*')

I tried change min_infix_len to min_prefix_len. Nothing work.

gvozd1989
  • 300
  • 1
  • 16
  • When you say you changed `min_index_len` etc, how did you change it? You can't change most index settings on the fly. Need to delete the index, change the config, then rebuild the index (inserting all data again). Also note that `prefix_fields` doesnt work with RT indexes (or more correctly `dict=keywords`). Also you have `expand_keywords=1`, so shouldnt need to add the stars manually (ie first example should work) – barryhunter Feb 17 '17 at 10:03
  • Yes, my mistake was, that I don't delete data files from filesystem. – gvozd1989 Feb 18 '17 at 14:43

2 Answers2

1

My mistake was, that I don't delete data files from filesystem, when change config, this is final working config:

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
}
gvozd1989
  • 300
  • 1
  • 16
0

I faced the same problem. Deleting the index files helps me too. Before deleting I stop the searchd service and then restart it.