# How to get documents added as-is due to fields with dot in them?

**URL:** <https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165>\
**Category:** Elasticsearch\
**Created:** [August 19, 2024, 6:59pm UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165 "2024-08-19T18:59:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Carter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_carter/32/136903_2.png) [@Michael\_Carter](https://discuss.elastic.co/u/Michael_Carter)\
**Post date:** [August 19, 2024, 6:59pm UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165/1 "2024-08-19T18:59:15Z")

</div>

So basically I've got this json file being generated by a system that didn't know how to write json files.

Here's the example of my problem:

```auto
{"snapshot.updated_by.uid": "mcarter", 
 "snapshot.updated_by": "michael carter"}

```

So how do I get Elasticsearch to escape that .?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [August 20, 2024, 1:25am UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165/2 "2024-08-20T01:25:57Z")

</div>

Hello and welcome,

What is exactly your issue? And what you want the output to be?

The document you shared has 2 fields with literal dots in the name.

---

<div class="post-metadata">

**Author:** ![Michael\_Carter](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michael_carter/32/136903_2.png) [@Michael\_Carter](https://discuss.elastic.co/u/Michael_Carter)\
**Post date:** [August 20, 2024, 3:08am UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165/3 "2024-08-20T03:08:41Z")

</div>

I'd like it to use the . in the field name rather than separating the mapping into two/three separate fields.

Because of the overlap I get an error trying to add the document.

```auto
Failure to add document: co.elastic.clients.elasticsearch._types.ElasticsearchException@3fefbb9c[
  response=ErrorResponse: {"error":{"type":"document_parsing_exception","reason":"[1:1453] failed to parse field [snapshot.updated_by] of type [text] in document with id

```

and this one

```auto
Error saving mapping

Error saving mapping: can't merge a non object mapping [snapshot.updated_by] with an object mapping

```

Also if the field starts with a . like {".myfield": "data"} I get an error that the field name can't contain whitespace.

So how do I get Elasticsearch to stop using the . as a delimiter?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 20, 2024, 3:37am UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165/4 "2024-08-20T03:37:41Z")

</div>

I don't think you can.  
I'd change the field names on the client side and replace all dots by another character like - or \_.

Could you share a bit more of your code? How do you index a document?

---

<div class="post-metadata">

**Author:** ![Julian\_Fazri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/julian_fazri/32/15921_2.png) [@Julian\_Fazri](https://discuss.elastic.co/u/Julian_Fazri)\
**Post date:** [August 20, 2024, 6:58am UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165/5 "2024-08-20T06:58:23Z")

</div>

Hi, I think you can use nested field format like [snapshot][updated\_by] format so the elastic field will become snapshot.updated\_by.

I don't know this is the escape you find or not.

---

<div class="post-metadata">

**Author:** ![Kathleen\_DeRusso](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kathleen_derusso/32/132039_2.png) [@Kathleen\_DeRusso](https://discuss.elastic.co/u/Kathleen_DeRusso)\
**Post date:** [August 20, 2024, 12:33pm UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165/6 "2024-08-20T12:33:51Z")

</div>

The dot character is reserved as it indicates flattened fields.

You have two options:

1. You can use a different character for a delimiter for example `_`:

```auto
{"snapshot_updated_by_uid": "mcarter", 
 "snapshot_updated_by": "michael carter"}

```

1. You can refactor this to reflect nested fields, which is what the dots represent:

```auto
{"snapshot.updated_by.uid": "mcarter", 
 "snapshot.updated_by.name": "michael carter"}

```

This example would be the same as sending in:

```auto
{
  "snapshot": {
    "updated_by": {
      "uid": "mcarter",
      "name": "michael carter"
    }
}

```

---

<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:** [September 17, 2024, 12:34pm UTC](https://discuss.elastic.co/t/how-to-get-documents-added-as-is-due-to-fields-with-dot-in-them/365165/7 "2024-09-17T12:34:28Z")

</div>

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