我希望将立陶宛字符替换为拉丁字符:
analysis:
char_filter :
lt_characters :
type : mapping,
mappings : ['ą' => 'a','Ą' => 'a','č' => 'c','Č' => 'c','ę' => 'e','Ę' => 'e','ė' => 'e','Ė' => 'e','į' => 'i','Į' => 'i','š' => 's','Š' => 's','ų' => 'u','Ų' => 'u','Ų' => 'u','ū' => 'u','ž' => 'z']
但是出了点问题,我认为elasticsearch不理解我的角色,我得到错误:
-bash-4.1$ /usr/local/bin/php54-cli app/console fos:elastica:populate
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Cannot import resource "/home/katalogas/domains/ekatalogas.eu/public_html/app/config/config.yml" from "/home/katalogas/domains/ekatalogas.eu/public_html/app/config/config_dev.yml". (Unexpected characters ( => 'a','Ą' => 'a','č' => 'c','Č' => 'c','ę' => 'e','Ę' => 'e','ė' => 'e','Ė' => 'e','į' => 'i','Į' => 'i','š' => 's','Š' => 's','ų' => 'u','Ų' => 'u','Ų' => 'u','ū' => 'u','ž' => 'z']) at line 86 (near "mappings : ['ą' => 'a','Ą' => 'a','č' => 'c','Č' => 'c','ę' => 'e','Ę' => 'e','ė' => 'e','Ė' => 'e','į' => 'i','Į' => 'i','š' => 's','Š' => 's','ų' => 'u','Ų' => 'u','Ų' => 'u','ū' => 'u','ž' => 'z']").)
[Symfony\Component\Yaml\Exception\ParseException]
Unexpected characters ( => 'a','Ą' => 'a','č' => 'c','Č' => 'c','ę' => 'e','Ę' => 'e','ė' => 'e','Ė' => 'e','į' => 'i','Į' => 'i','š' => 's','Š' => 's','ų' => 'u','Ų' => 'u','Ų' => 'u','ū' => 'u','ž' => 'z']) at line 86 (near "mappings : ['ą' => 'a','Ą' => 'a','č' => 'c','Č' => 'c','ę' => 'e','Ę' => 'e','ė' => 'e','Ė' => 'e','į' => 'i','Į' => 'i','š' => 's','Š' => 's','ų' => 'u','Ų' => 'u','Ų' => 'u','ū' => 'u','ž' => 'z']").
如何通过替换来解决这个问题?
答案 0 :(得分:1)
Elasticsearch会理解这一点:
"analysis": {
"char_filter": {
"lt_characters": {
"type": "mapping",
"mappings": [
"ą=>a",
"Ą=>a",
"č=>c",
"Č=>c",
"ę=>e",
"Ę=>e",
"ė=>e",
"Ė=>e",
"į=>i",
"Į=>i",
"š=>s",
"Š=>s",
"ų=>u",
"Ų=>u",
"ū=>u",
"ž=>z"
]
}
}
您不必将每个字符放在引号之间,而是整个映射:"ą=>a"
。