如何设置实时索引属性类型

时间:2019-12-06 14:11:23

标签: sphinx

我有一个索引,我想在其中插入,更新和删除具有实时索引的行,但是index_rt错误。

这是常见的索引配置:

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
}

这是一个实时配置:

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
}

,这里将两个索引合并为一个:

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

然后当我尝试插入新记录时:

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

第三个字段currency_id必须为整数类型,为什么要使用字符串?我不明白(

1 个答案:

答案 0 :(得分:1)

首先,RT索引没有“源”。它们直接包含数据,而不是从远程源加载。指定source=可能并不正确,但是将被忽略

RT索引根据rt_fieldrt_attr_*伪指令创建其架构。


因此,架构不会与本地/磁盘索引相同。

通常,其顺序与索引定义中定义的顺序相同,但可以有所不同(如果索引已经过编辑)

...最好运行DESCRIBE jobResumeRT来查找索引中所有列的实际顺序。然后,在不命名列的情况下进行INSERT等操作时,请按从DESCRIBE返回的相同顺序插入列。

或通过以相同顺序命名命令中的列来进行插入。实际上可能会更好,因为可以立即插入到字符串属性和字段中。