You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ElasticSearch导入CSV时遇expected value but got [START_ARRAY]错误求助

错误原因定位

你的查询语句里filter下bool查询的must字段格式错误,错误信息中的expected value but got [START_ARRAY],就是因为该字段使用了双层嵌套数组,超出了ElasticSearch的解析规则。

问题出在这段代码:

"must": [
    [{
        "term": {
            "type": "resource"
        }
    }, {
        "term": {
            "type_id": 335
        }
    }]
]

ElasticSearch的bool查询中,must、should等参数仅接受查询条件对象的一维数组,你在这里给两个term条件额外套了一层数组,导致解析失败。

修正后的查询语句

去掉内层嵌套的数组,直接将两个term条件放在must的一维数组中即可:

{
    "index": "collection_items",
    "body": {
        "_source": "*",
        "track_total_hits": true,
        "from": 0,
        "size": 24,
        "sort": {
            "updated_at": "desc"
        },
        "query": {
            "bool": {
                "should": [{
                    "match": {
                        "title.english": {
                            "query": "",
                            "boost": 15
                        }
                    }
                }],
                "must": [{
                    "query_string": {
                        "query": "*",
                        "fields": ["*"],
                        "default_operator": "and"
                    }
                }],
                "filter": {
                    "bool": {
                        "must_not": [{
                            "terms": {
                                "extra_data.user_type": ["group_leader", "person", "organization"]
                            }
                        }, {
                            "term": {
                                "type": "group_leader"
                            }
                        }, {
                            "term": {
                                "extra_data.disabled": "true"
                            }
                        }, {
                            "term": {
                                "extra_data_type": "favorites"
                            }
                        }],
                        "must": [
                            {
                                "term": {
                                    "type": "resource"
                                }
                            }, {
                                "term": {
                                    "type_id": 335
                                }
                            }
                        ]
                    }
                }
            }
        }
    }
}
补充说明

如果你的需求是让两个term条件满足逻辑与(即同时匹配type=resource和type_id=335),直接放在must数组里即可——bool查询的must默认就是逻辑与关系,无需额外嵌套数组。

内容的提问来源于stack exchange,提问作者pepperoo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 23:32:33