Nested Objects in Elastic

Hi, I have a data in the following format. I'm trying with ELastic 7.6 and using Kibana.

{"l1f1":"f1Value","l1f2":[{"l2f1":"l1f1Value","l2f2":"l2f2Value","l2f3":"l2f3Value"}]}

I want to index this data using bulk insert operation. My Index creation script is

 {
	"settings": {
		"analysis": {
			"analyzer": {
				"Custom_Casing_Analyzer": {
					"type": "custom",
					"tokenizer": "keyword",
					"filter": [
						"lowercase","uppercase"
					]
				}
			}
		}
	},
	"mappings":{ "properties": { "l1f2":{"type": "nested"} }}
}

I want that l1f2 field to be nested. but I'm getting the following error

{"took":6,"errors":true,"items":[{"index":{"_index":"dummy1","_type":"dummy1","_id":"f1Value","status":400,"error":{"type":"illegal_argument_exception","reason":"object mapping [l1f2] can't be changed from nested to non-nested"}}}

Can you tell me what should be the proper approach for this?

@dadoonet can you help. I have tried your solution in the link Index Mapping Issue - Getting Error: "reason" : "object mapping [locations] can't be changed from nested to non-nested" But I'm using Elastic 7.6, so that solution didn't worked.

I tried this (7.7.1):

DELETE test 
PUT test
{
  "mappings": {
    "properties": {
      "l1f2": {
        "type": "nested"
      }
    }
  }
}
POST test/_doc
{
  "l1f1": "f1Value",
  "l1f2": [
    {
      "l2f1": "l1f1Value",
      "l2f2": "l2f2Value",
      "l2f3": "l2f3Value"
    }
  ]
}

This worked well:

{
  "_index" : "test",
  "_type" : "_doc",
  "_id" : "-JNsmXIBwdOO0y9Zttmx",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 2,
    "failed" : 0
  },
  "_seq_no" : 0,
  "_primary_term" : 1
}

Hi @dadoonet , This Worked well, The Mistake I have done in the above is not assigning the "_doc" while adding the data.
Previously it used to be the type name.
What is the significance of this "_doc"
Can you help me with any tutorials on Latest Elastic Integration with C#?

Thanks,
Ayyappa

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.