gpt4 book ai didi

symfony - Elasticsearch替换特殊字符

转载 作者:行者123 更新时间:2023-12-03 02:03:51 25 4
gpt4 key购买 nike

我想将立陶宛字符替换为拉丁字符:

 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']").

如何用替换来解决这个问题?

最佳答案

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"

关于symfony - Elasticsearch替换特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28782578/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com