Search code examples
sphinx

how to set realtime index attribute type


I have an index where I would like insert, update and delete rows with realtime index but a index_rt wrong works.

It's a common index config:

index jobResumeIndex
{
    source          = jobResumeSource
    path            = {{path_to_data}}/{{data_file_name}}/jobResumeIndex
    morphology      = stem_enru
    charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+401->U+0435, U+451->U+0435
    min_prefix_len = 3
    #min_infix_len = 3
    index_exact_words = 1
    expand_keywords = 1
}

and it is a real time config:

index jobResumeRT
{
    type            = rt
    source          = jobResumeSource
    path            = {{path_to_data}}/{{data_file_name}}/jobResume

    #Список полей для записи
    rt_field = post
    rt_field = wage
    rt_field = currency_id
    rt_field = tariff_rate_id
    rt_field = business_trip_id
    rt_field = work_experience_id
    rt_field = citizenship_id
    rt_field = geo_place_id
    rt_field = age
    rt_field = gender
    rt_field = only_with_avatar
    rt_field = only_with_portfolio
    rt_field = only_with_wage
    rt_field = visible
    rt_field = status
    rt_field = updated_at
    rt_field = about_me
    rt_field = fio
    rt_field = work_permit_ids
    rt_field = prof_area_ids
    rt_field = driver_license_ids
    rt_field = skills
    rt_field = employment_ids
    rt_field = schedule_ids
    rt_field = education_ids
    rt_field = contacts
    rt_field = language_codes
    rt_field = experience_text
    rt_field = portfolio_text
    rt_field = course_text

    rt_attr_string = post
    rt_attr_uint = wage
    rt_attr_uint = currency_id
    rt_attr_uint = tariff_rate_id
    rt_attr_uint = business_trip_id
    rt_attr_uint = work_experience_id
    rt_attr_uint = citizenship_id
    rt_attr_uint = geo_place_id
    rt_attr_uint = age
    rt_attr_uint = gender
    rt_attr_uint = only_with_avatar
    rt_attr_uint = only_with_portfolio
    rt_attr_uint = only_with_wage
    rt_attr_uint = visible
    rt_attr_uint = status
    rt_attr_uint = updated_at
    rt_attr_string = about_me
    rt_attr_string = fio
    rt_attr_string = work_permit_ids
    rt_attr_string = prof_area_ids
    rt_attr_string = driver_license_ids
    rt_attr_string = skills
    rt_attr_string = employment_ids
    rt_attr_string = schedule_ids
    rt_attr_string = education_ids
    rt_attr_string = contacts
    rt_attr_string = language_codes
    rt_attr_string = experience_text
    rt_attr_string = portfolio_text
    rt_attr_string = course_text

    rt_mem_limit = 512M

    morphology      = stem_enru
    charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+401->U+0435, U+451->U+0435
    min_prefix_len = 3
    index_exact_words = 1
    expand_keywords = 1
}

and it's here combine both indexs in one:

index jobResume
{
    type = distributed
    local = jobResumeIndex
    local = jobResumeRT
}

then when I trying insert new record:

mysql> insert into jobResumeRT  values(119,'Инженер - инспектор по безопасности полетов',0,190,193,7,15,0,538560,'14',1,1,0,0,1,2,'1575616137','','Иван Иванов ','','12,211','','{1057369: PHP (PHP4, PHP5, PHP5.5, HPHP)}','1','10','1234567898','','','','','');

ERROR 1064 (42000): row 1, column 3: string expected

third field currency_id must be an integer type, why string expected? I don't understand(


Solution

  • Firstly RT indexes DON'T have a 'source'. They contain the data directly, not loading from a remote source. It might not be an erorr to specify source=, but will be ignored

    RT indexes create their schema, from the rt_field and the rt_attr_* directives.


    As such the schema won't be the same as the local/disk index. Will usually be same order as defined in index defintion, but can vary (if index has undergone edits)

    ... best to run a DESCRIBE jobResumeRT to find the actual order of all the columns in the index. Then when doing an INSERT etc without naming the columns, insert the columns in same order as returned from DESCRIBE.

    Or do an insert, by naming the columns in the command, in same order. This may actually be better, as can then insert into a string attribute and field at once.