【问题标题】:Multiple searches with FOSElasticaBundle for a keyword使用 FOSElasticaBundle 多次搜索关键字
【发布时间】:2014-04-01 02:59:59
【问题描述】:

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

【问题讨论】:

    标签: symfony elasticsearch foselasticabundle


    【解决方案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 会自动完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      • 2021-08-23
      • 2012-09-09
      相关资源
      最近更新 更多