小编Dav*_*ham的帖子

检查Elastic Search中数组是否包含具有特定字段的对象?

我是 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)

search filter match elasticsearch

2
推荐指数
1
解决办法
4849
查看次数

从 types.JSON.TEXT 转换为字符串列表

我有一个 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)

还有其他方法可以实现此目的,或者如何摆脱反斜杠?

string text json trim go

0
推荐指数
1
解决办法
1397
查看次数

标签 统计

elasticsearch ×1

filter ×1

go ×1

json ×1

match ×1

search ×1

string ×1

text ×1

trim ×1