-1

I am getting below error when i try to create the mapping using create index request.

Elasticsearch exception [type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [recommendations : {recommendations={properties={events={type=nested, properties={recommendationData={type=nested, properties={recommendations={type=nested, properties={recommendationType={type=keyword}}}}}}}}}}]]

and the mapping is

{
  "mappings": {
    "recommendations": {
      "properties": {
        "events": {
          "type": "nested",
          "properties": {
            "recommendationData": {
              "type": "nested",
              "properties": {
                "recommendations": {
                  "type": "nested",
                  "properties": {
                    "recommendationType": {
                      "type": "keyword"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

and the java code is

private void checkAndCreateDocumentMapping() throws IOException {

        CreateIndexRequest createIndexRequest = new CreateIndexRequest(this.getIndexName());
        String indexString = getStringFromFile("nested" + ".mapping");
        createIndexRequest.source(indexString, XContentType.JSON);
        client.indices().create(createIndexRequest, RequestOptions.DEFAULT);
    }
Logemann
  • 2,767
  • 33
  • 53
Tirumalesh
  • 95
  • 1
  • 17

1 Answers1

1

Please note that elasticsearch no more support multiple mappings therefore it is no more required to pass mapping name. Assuming recommendations is name of mapping, it can be instead used as name of index. Therefore correct dsl to create index should be,

PUT recommendations
{
  "mappings": {
    "properties": {
      "events": {
        "type": "nested",
        "properties": {
          "recommendationData": {
            "type": "nested",
            "properties": {
              "recommendations": {
                "type": "nested",
                "properties": {
                  "recommendationType": {
                    "type": "keyword"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Nishant
  • 7,504
  • 1
  • 21
  • 34
  • Yes you are correct recommendations is the mapping type but if i remove it will throw another exception – Tirumalesh Apr 15 '20 at 04:12
  • ElasticsearchStatusException[Elasticsearch exception [type=mapper_parsing_exception, reason=Failed to parse mapping [_doc]: No type specified for field [properties]]]; nested: ElasticsearchException[Elasticsearch exception [type=mapper_parsing_exception, reason=No type specified for field [properties]]]; – Tirumalesh Apr 15 '20 at 04:12
  • You seems to be using older client. Make sure the client version matches the elastisearch version – Nishant Apr 15 '20 at 04:18
  • it's not me.. for me issue is fixed your answer is correct i am supposed to use older version. – Tirumalesh Apr 15 '20 at 06:18