Default Mapping Setup

I have been trying to set up default mappings for a brand new index and I keep getting errors.

This is what I am doing

PUT /documents
  mappings": {
    "_default_: {
      "title": {"type": "string"},
      "author": {"type": "string"},
      "description": {"type": "string"},
      "tags": {"type": "string"},
      "country": {"type": "string"},
      "version": {"type": "double"},
      "revisions": {"type": "string"},
      "createdAt": {"type": "date"},
      "updatedAt": {"type": "date"},
      "fileType": {"type": "string"},
      "urlToFile": {"type": "string"},
      "archived": {"type": "boolean"},
      "archivedDate": {"type": "date"},
      "archivedReason": {"type": "string"}

And then the error that I am getting is:

{"error":"ElasticsearchParseException[failed to parse source for create index]; nested: JsonParseException[Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in name\n at [Source: [B@75dfe5d5; line: 3, column: 17]]; ","status":400}

Does anyone have any ideas?

You are missing a " character after _default:

You are also missing a " before mappings:

Ah yeah that was silly.

However I have fixed that and still not having any luck.

I am still getting the same error :confused:

Never mind. But I do have a different error now :confused:

{"error":"MapperParsingException[mapping [_default_]]; nested: MapperParsingException[Root type mapping not empty after parsing! Remaining fields:   [archivedDate : {type=date}] [country : {type=string}] [urlToFile : {type=string}] [author : {type=string}] [description : {type=string}] [title : {type=string}] [version : {type=double}] [tags : {type=string}] [createdAt : {type=date}] [archived : {type=boolean}] [revisions : {type=string}] [fileType : {type=string}] [archivedReason : {type=string}] [updatedAt : {type=date}]]; ","status":400} 

Any ideas on this one? @colings86

You need to have a "properties":{} object under _default_ and put your fields in there. see for more information on setting mappings

1 Like

Ah that has worked.

Thank you :smile: