How to search with original keyword and transformed keyword? I have indexed data like this with 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"
}
Now, when people want to search for keyword phòng
, I want to search for keyword phong
(transformed from phòng
) as well but the former should be scored higher than the latter.
How to do it with FOSElasticaBundle or with ElasticSearch?
Just found a solution:
analysis:
analyzer:
post_analyzer:
tokenizer: lowercase
filter: [ standard, my_ascii_folding ]
filter:
my_ascii_folding:
type: asciifolding
preserve_original: true
Then post_analyzer
need to be applied to the fields content
. And content_canonical
is not needed as asciifolding
will do it automatically.