# Parsing issues with nested data

**URL:** <https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608>\
**Category:** Elasticsearch\
**Created:** [January 15, 2018, 11:07pm UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608 "2018-01-15T23:07:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ataustin](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@ataustin](https://discuss.elastic.co/u/ataustin)\
**Post date:** [January 15, 2018, 11:07pm UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/1 "2018-01-15T23:07:04Z")

</div>

Hello ES experts,  
We are running into an issue with certain documents that are ingested in by transport-couchbase. The doc is and error is listed below. Any ideas

`[{ "poc": { "cas": 1511944677515919400, "docType": "Game", "docVersion": "1.0", "gameId": "4d77c7a3-c3d6-4b59-9283-08add213420d", "gameState": { "jackpot": 0, "some3History": [ null], "some5History": [null] }, "gameType": "SomeGame", "guests": [], "index": 0, "isActive": true, "parentId": null, "serverFullName": null, "updateTimestamp": "2017-11-29T08:37:57.565371+00:00" } } ]`

the error is:

```auto
[2018-01-15T17:06:17,340][ERROR][o.e.t.c.c.CouchbaseCAPITransportImpl] [kYdTvkJ] bulk index requestId=42898 Failing due to errors: MapperParsingException[failed to parse [doc.gameState]]; nested: IllegalStateException[Can't get text on a START_OBJECT at 1:360];

[2018-01-15T17:06:17,340][WARN][o.e.j.s.ServletHandler] /poc-sandbox%2f423/_bulk_docs
java.lang.RuntimeException: MapperParsingException[failed to parse [doc.gameState]]; nested: IllegalStateException[Can't get text on a START_OBJECT at 1:360];

	at org.elasticsearch.transport.couchbase.capi.ElasticSearchCAPIBehavior.bulkDocs(ElasticSearchCAPIBehavior.java:548) ~[elasticsearch-transport-couchbase-3.0.0-cypress-es5.6.4-all.jar:?]
	at com.couchbase.capi.servlet.CAPIServlet.handleBulkDocs(CAPIServlet.java:532) ~[couchbase-capi-server-1.6.3.jar:?]
	at com.couchbase.capi.servlet.CAPIServlet.service(CAPIServlet.java:89) ~[couchbase-capi-server-1.6.3.jar:?]
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[javax.servlet-api-3.1.0.jar:3.1.0]
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:845) ~[jetty-servlet-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:584) [jetty-servlet-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:513) [jetty-security-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226) [jetty-server-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1180) [jetty-server-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:512) [jetty-servlet-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) [jetty-server-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1112) [jetty-server-9.3.13.v20161014.jar:9.3.13.v20161014]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.3.13.v20161014.jar:9.3.
```

---

<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:** [January 16, 2018, 4:18am UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/2 "2018-01-16T04:18:29Z")

</div>

Pretty sure that your mapping says that gamestate is a text field and here you try to put an object for that field.

Check your mapping.

---

<div class="post-metadata">

**Author:** ![ataustin](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@ataustin](https://discuss.elastic.co/u/ataustin)\
**Post date:** [January 16, 2018, 4:32am UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/3 "2018-01-16T04:32:41Z")

</div>

Thanks David! I actually do not have have any mapping for gameState. Here is my mapping:

```auto
    "template" : "*",
    "order" : 10,
    "mappings" : {
        "couchbaseCheckpoint" : {
            "_source" : {
                "includes" : ["doc.*"]
            },
            "dynamic_templates": [
                {
                        "longs_as_strings": {
                                "match": "[doc.id]",
                                "mapping": {
                                        "type": "text"
                                }
                        }
                },
                {
                        "longs_as_floats": {
                                "match": "[doc.bridgeServerBalanceAmount]",
                                "mapping": {
                                        "type": "float"
                                }
                        }
                },
                {
                    "store_no_index": {
                        "match": "*",
                        "mapping": {
                            "store" : "no",
                            "index" : "no",
                            "include_in_all" : false
                        }
                    }
                }
            ]
        },
        "doc": {
                "properties": {
                        "id": { "type": "text" } ,
                        "doc.id": { "type": "text" }
                }
        },
        "_default_" : {
            "_source" : {
                "includes" : ["meta.*","doc.*"]
            },
            "properties" : {
                "meta" : {
                    "type" : "object",
                    "include_in_all" : false
                }
            }
        }
    }
}
```

---

<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:** [January 16, 2018, 6:14am UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/4 "2018-01-16T06:14:12Z")

</div>

This is a template not the actual mapping.

---

<div class="post-metadata">

**Author:** ![ataustin](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@ataustin](https://discuss.elastic.co/u/ataustin)\
**Post date:** [January 16, 2018, 1:54pm UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/5 "2018-01-16T13:54:38Z")

</div>

Thanks David! I use the DefaultTypeSelector for the mapping - [https://github.com/couchbaselabs/elasticsearch-transport-couchbase/releases/tag/2.1.1-RC](https://github.com/couchbaselabs/elasticsearch-transport-couchbase/releases/tag/2.1.1-RC). For gameState why would it be an issue?

---

<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:** [January 16, 2018, 2:20pm UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/6 "2018-01-16T14:20:56Z")

</div>

I don't know. But what is the current mapping?

```auto
GET poc-sandbox%2f423/_mapping

```

---

<div class="post-metadata">

**Author:** ![ataustin](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@ataustin](https://discuss.elastic.co/u/ataustin)\
**Post date:** [January 16, 2018, 3:41pm UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/7 "2018-01-16T15:41:29Z")

</div>

Thanks David, you are right. The mapping says it is a text. Since this was auto-generated,

- how do I override the auto-generated mapping just for one of the properties, in this case, gameState?
- And what is there is at least one document that has gameState a string while others are an object? How do I handle hybrid types especially string / object?

Thanks again

---

<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:** [January 16, 2018, 4:05pm UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/8 "2018-01-16T16:05:35Z")

</div>

> how do I override the auto-generated mapping just for one of the properties, in this case, gameState?

If you provide a template with this field, it will applied. If this field does not exist, auto-generated mapping for this field will be applied.

> How do I handle hybrid types especially string / object?

You can't. You need to fix the problem before indexing in elasticsearch.

---

<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 13, 2018, 4:05pm UTC](https://discuss.elastic.co/t/parsing-issues-with-nested-data/115608/9 "2018-02-13T16:05:44Z")

</div>

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