Search code examples
elasticsearchsearchindexingdocumentelasticsearch-6

Attempt to index document gives error: "only value lists are allowed in serialized settings"


When attempting to index the following document:

{
"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"
}

I get the following error:

{"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}

From which I've gathered that the main issues are either described in the part saying that:

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

Or:

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

But I cannot find any information about this error or what it could be caused by. I've tried indexing both using a predefined index with mappings and to a non-existing index. Nothing seems to work.

Why can't I index this document?


Solution

  • It turns out that, as Farid mentioned in the comments section, I was using the wrong command when indexing from the command line.

    The correct command to run is

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

    Where the key is that you use POST and not PUT which is what I was doing.