0

如何使用原始关键字和转换后的关键字进行搜索?我用 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 做到这一点?

4

1 回答 1

1

刚刚找到一个解决方案:

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

然后post_analyzer需要应用到领域content。并且content_canonical不需要,因为asciifolding它会自动执行。

于 2014-04-01T18:09:26.790 回答