2014-04-01 112 views
0

如何使用原始关键字和转换后的关键字进行搜索? 我已经收录这样的数据与弹性曲线:使用FOSElasticaBundle进行多个关键字搜索

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

就找到了解决办法:

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

然后post_analyzer需要应用到田间地头contentcontent_canonical不需要,因为asciifolding会自动完成。