Does Elastic accept combined JSON with flatten keys

Hi,

is it possible to send to ES messages in combined JSON format

{
  "a": {
    "b": {
      "c.d.e.f": "value"
    }
  }
}

or it ends with error like can't merge a non object mapping with an object mapping?

Hi @ddoroshenko ,
It is possible to index the above document with the following:

POST index1/_doc
{
  "a": {
    "b": {
      "c.d.e.f": "value"
    }
  }
}

But, bear in mind that Elasticsearch treats fields with dots in their names as objects meaning that the above is equivelant to this:

{
  "a": {
    "b": {
      "c": {
	    "d": {
		  "e": {
		    "f": "value"
		  }
		}
	  }
    }
  }
}

You can also view this using GET _mapping API on the index1:

{
  "index1": {
    "mappings": {
      "properties": {
        "a": {
          "properties": {
            "b": {
              "properties": {
                "c": {
                  "properties": {
                    "d": {
                      "properties": {
                        "e": {
                          "properties": {
                            "f": {
                              "type": "text",
                              "fields": {
                                "keyword": {
                                  "type": "keyword",
                                  "ignore_above": 256
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Ofir

1 Like

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