使用FOSElasticaBundle对关键字进行多次搜索

时间:2014-04-01 02:59:59

标签: symfony elasticsearch foselasticabundle

如何使用原始关键字和已转换的关键字进行搜索? 我用Elastica索引了这样的数据:

id1: {
    content: "Phòng tránh rủi ro",
    content_canonical: "Phong tranh rui ro"
},
id2: {
    content: "Phóng nhanh vượt ẩu",
    content_canonical: "Phong nhanh vuot au"
},
id3: {
    content: "Mô phỏng thực tế",
    content_canonical: "Mo phong thuc te"
}

现在,当人们想要搜索关键字phòng时,我想要搜索关键字phong(从phòng转换而来),但前者的得分应高于后者

如何使用FOSElasticaBundle或ElasticSearch进行操作?

1 个答案:

答案 0 :(得分:1)

刚刚找到解决方案:

                analysis:
                    analyzer:
                        post_analyzer:
                            tokenizer: lowercase
                            filter: [ standard, my_ascii_folding ]
                    filter:
                        my_ascii_folding:
                            type: asciifolding
                            preserve_original: true

然后post_analyzer需要应用于字段content。 <{1}}不需要content_canonical,因为asciifolding会自动执行此操作。

相关问题