# Elasticsearch Question, Disable nesting

**URL:** <https://discuss.elastic.co/t/elasticsearch-question-disable-nesting/324207>\
**Category:** Elasticsearch\
**Created:** [January 30, 2023, 9:29am UTC](https://discuss.elastic.co/t/elasticsearch-question-disable-nesting/324207 "2023-01-30T09:29:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tglanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tglanz/32/116508_2.png) [@tglanz](https://discuss.elastic.co/u/tglanz)\
**Post date:** [January 30, 2023, 9:29am UTC](https://discuss.elastic.co/t/elasticsearch-question-disable-nesting/324207/1 "2023-01-30T09:29:49Z")

</div>

Hi,

I have a scenario with documents of the form:

```auto
{
  "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"](https://www.elastic.co/guide/en/elasticsearch/reference/current/flattened.html) 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!

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 31, 2023, 7:02am UTC](https://discuss.elastic.co/t/elasticsearch-question-disable-nesting/324207/2 "2023-01-31T07:02:19Z")

</div>

> [@tglanz](#):
>
> My question is if there is any way to disable this nesting behavior for the specific field "properties"?

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 28, 2023, 7:02am UTC](https://discuss.elastic.co/t/elasticsearch-question-disable-nesting/324207/3 "2023-02-28T07:02:29Z")

</div>

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