我是 Elastic Search 的新手,我的数据具有以下形式:
索引映射
{
"company:product:index": {
"aliases": {},
"mappings": {
"company:product:mapping": {
"properties": {
"attribute_heel-style": {
"properties": {
"label": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"source": {
"type": "keyword"
},
"value": {
"type": "keyword"
},
"value_label": {
"type": "keyword"
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
指数数据
{
"attribute_heel-style": [
{
"name": "heel-style",
"label": "Heel Style",
"value": "stiletto",
"value_label": "Stiletto"
},
{
"name": "heel-style",
"label": "Heel Style",
"value": "wedge"
"value_label": "Wedge"
},
... // …Run Code Online (Sandbox Code Playgroud) 我有一个 JSON.TEXT (https://godoc.org/github.com/jmoiron/sqlx/types#JSONText),我需要将其转换为字符串列表。例如,如何转换
`["equals", "less than"]` // JSON.TEXT type
Run Code Online (Sandbox Code Playgroud)
到
["equals", "less than"] // list of strings
Run Code Online (Sandbox Code Playgroud)
我试图通过使用string()、修剪[和]括号并将它们连接起来来显式转换 JSON.TEXT 类型,但我最终得到了一个带有奇怪反斜杠的字符串数组:
["\"equal to\"", " \"less than equal to\""]
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以实现此目的,或者如何摆脱反斜杠?