Elasticsearch Question, Disable nesting

Hi,

I have a scenario with documents of the form:

{
  "field": "some value",
  "properties": {
    "a": "some value of a",
    "a.b": "some value of a.b"
  }
}

I would like to have the following capabilities:

  1. Search and filter according to any of the "properties" fields
  2. Query for all "properties" fields of all documents (with some criteria such as time frame)

Some important things to note are

  1. Under the "properties" object, all fields, namely "a" and "a.b" are just names. The "." doesn't imply nesting.
  2. There could be arbitrary number, with arbitrary fields in "properties" object.

When trying to put the above doc I get the following error:

can't merge a non object mapping [properties.a] with an object mapping

From what I understand, because of the "." in "a.b", Elasticsearch maps "properties.a" to an object. Then, when trying to map the "properties.a" field as string it is in conflict.

My question is if there is any way to disable this nesting behavior for the specific field "properties"? I want to have those fields flat.

I have tried using the "flattened" type. This looked promising at first, but my issue is that I cannot query for all of the available fields in "properties" which is required.

Any ideas will be greatly appreciated, Thanks!

As far as I know there is not. You would need to replace the dot in the names with some other character, e.g. underscore.

1 Like

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