首页 > 解决方案 > 尝试索引文档会出错:“序列化设置中只允许值列表”

问题描述

尝试索引以下文档时:

{
"branch": "master",
"classes": [
    {
        "content_count": 2,
        "documentation": "",
        "extends": [],
        "generic": "",
        "implements": [],
        "line": 10,
        "line_count": 36,
        "modifiers": [
            "public"
        ],
        "name": "removeDuplicateFromString"
    }
],
"commit_hash": "e53249ba2381d2f20f3d4493ad70e2da0abb3b05",
"contributors": [
    {
        "id": "7676016",
        "name": "varunu28",
        "url": "https://github.com/varunu28"
    }
],
"enums": [],
"fields": [],
"filename": "removeDuplicateFromString.java",
"imports": [
    {
        "name": "java.io.BufferedReader",
        "wildcard": false
    },
    {
        "name": "java.io.InputStreamReader",
        "wildcard": false
    }
],
"interfaces": [],
"license": "",
"methods": [
    {
        "cyclomatic_complexity": 1,
        "documentation": "",
        "generic": "",
        "line": 11,
        "line_count": 9,
        "modifiers": [
            "public",
            "static"
        ],
        "name": "main",
        "params": [
            {
                "name": "args",
                "type": "String[]"
            }
        ],
        "parent": "removeDuplicateFromString",
        "type_": "void"
    },
    {
        "cyclomatic_complexity": 5,
        "documentation": "",
        "generic": "",
        "line": 29,
        "line_count": 16,
        "modifiers": [
            "public",
            "static"
        ],
        "name": "removeDuplicate",
        "params": [
            {
                "name": "s",
                "type": "String"
            }
        ],
        "parent": "removeDuplicateFromString",
        "type_": "String"
    }
],
"number_forks": 1695,
"number_stars": 4000,
"number_watchs": 394,
"package": "",
"path": "Others",
"repository": "TheAlgorithms/Java"
}

我收到以下错误:

{"error":{"root_cause":[{"type":"settings_exception","reason":"Failed to load settings from [{\"interfaces\":[],\"imports\":[{\"name\":\"java.io.BufferedReader\",\"wildcard\":false},{\"name\":\"java.io.InputStreamReader\",\"wildcard\":false}],\"package\":\"\",\"methods\":[{\"parent\":\"removeDuplicateFromString\",\"line_count\":9,\"line\":11,\"documentation\":\"\",\"name\":\"main\",\"cyclomatic_complexity\":1,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"args\",\"type\":\"String[]\"}],\"type_\":\"void\",\"generic\":\"\"},{\"parent\":\"removeDuplicateFromString\",\"line_count\":16,\"line\":29,\"documentation\":\"\",\"name\":\"removeDuplicate\",\"cyclomatic_complexity\":5,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"s\",\"type\":\"String\"}],\"type_\":\"String\",\"generic\":\"\"}],\"number_forks\":1695,\"classes\":[{\"implements\":[],\"line_count\":36,\"extends\":[],\"line\":10,\"documentation\":\"\",\"name\":\"removeDuplicateFromString\",\"content_count\":2,\"modifiers\":[\"public\"],\"generic\":\"\"}],\"repository\":\"TheAlgorithms/Java\",\"branch\":\"master\",\"commit_hash\":\"e53249ba2381d2f20f3d4493ad70e2da0abb3b05\",\"enums\":[],\"path\":\"Others\",\"license\":\"\",\"filename\":\"removeDuplicateFromString.java\",\"number_watchs\":394,\"contributors\":[{\"name\":\"varunu28\",\"id\":\"7676016\",\"url\":\"https://github.com/varunu28\"}],\"fields\":[],\"number_stars\":4000}]"}],"type":"settings_exception","reason":"Failed to load settings from [{\"interfaces\":[],\"imports\":[{\"name\":\"java.io.BufferedReader\",\"wildcard\":false},{\"name\":\"java.io.InputStreamReader\",\"wildcard\":false}],\"package\":\"\",\"methods\":[{\"parent\":\"removeDuplicateFromString\",\"line_count\":9,\"line\":11,\"documentation\":\"\",\"name\":\"main\",\"cyclomatic_complexity\":1,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"args\",\"type\":\"String[]\"}],\"type_\":\"void\",\"generic\":\"\"},{\"parent\":\"removeDuplicateFromString\",\"line_count\":16,\"line\":29,\"documentation\":\"\",\"name\":\"removeDuplicate\",\"cyclomatic_complexity\":5,\"modifiers\":[\"public\",\"static\"],\"params\":[{\"name\":\"s\",\"type\":\"String\"}],\"type_\":\"String\",\"generic\":\"\"}],\"number_forks\":1695,\"classes\":[{\"implements\":[],\"line_count\":36,\"extends\":[],\"line\":10,\"documentation\":\"\",\"name\":\"removeDuplicateFromString\",\"content_count\":2,\"modifiers\":[\"public\"],\"generic\":\"\"}],\"repository\":\"TheAlgorithms/Java\",\"branch\":\"master\",\"commit_hash\":\"e53249ba2381d2f20f3d4493ad70e2da0abb3b05\",\"enums\":[],\"path\":\"Others\",\"license\":\"\",\"filename\":\"removeDuplicateFromString.java\",\"number_watchs\":394,\"contributors\":[{\"name\":\"varunu28\",\"id\":\"7676016\",\"url\":\"https://github.com/varunu28\"}],\"fields\":[],\"number_stars\":4000}]","caused_by":{"type":"illegal_state_exception","reason":"only value lists are allowed in serialized settings"}},"status":500}

我从中收集到的主要问题要么在部分中描述,即:

{"type":"illegal_state_exception","reason":"only value lists are allowed in serialized settings"}}

或者:

"error":{"root_cause":[{"type":"settings_exception","reason":"Failed to load settings from [{\"interfaces\":[],\"imports\": ........

但我找不到有关此错误或其可能原因的任何信息。我尝试使用带有映射的预定义索引和不存在的索引进行索引。似乎没有任何效果。

为什么我不能索引这个文档?

标签: elasticsearchsearchindexingdocumentelasticsearch-6

解决方案


事实证明,正如 Farid 在评论部分提到的,我在从命令行索引时使用了错误的命令。

正确的运行命令是

curl -X POST -H 'Content-Type: application/json' [index location] -d [data]

关键是您使用 POST 而不是 PUT,这就是我正在做的。


推荐阅读