# Can't get text on START\_OBJECT

**URL:** <https://discuss.elastic.co/t/cant-get-text-on-start-object/162881>\
**Category:** Logstash\
**Created:** [January 4, 2019, 1:36am UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881 "2019-01-04T01:36:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Bassett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_bassett/32/45353_2.png) [@Mark\_Bassett](https://discuss.elastic.co/u/Mark_Bassett)\
**Post date:** [January 4, 2019, 1:36am UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/1 "2019-01-04T01:36:37Z")

</div>

Hi guys, I have some really bad source data that is giving me a mapping conflict when I try to ingest because sometimes it is a string value, and other times it is an array.

I've been fighting around with this for a while now, have tried many different things but nothing seems to be working.

```auto
{"m":"log_rgs","rgsResponseSummay":{"PrizeOutcome":[{"multiplier":"1","name":"BaseGame.Bonus","pay":"0","stage":"","totalPay":"0","type":"Pattern"},{"multiplier":"1","name":"BaseGame.Total","pay":"0","stage":"","totalPay":"0","type":"","Prize":{"betMultiplier":"1","multiplier":"1","name":"Total","pay":"0","payName":"","position":"0","symbolCount":"0","totalPay":"0","ways":"0"}},{"multiplier":"1","name":"BaseGame.Jackpot","pay":"0","stage":"","totalPay":"0","type":"Pattern"},{"multiplier":"1","name":"BaseGame.Lines","pay":"0","stage":"","totalPay":"0","type":"Pattern"},{"multiplier":"1","name":"SmartSound.Prize","pay":"0","stage":"","totalPay":"0","type":"Pattern"},{"multiplier":"1","name":"Game.Total","pay":"0","stage":"","totalPay":"0","type":"","Prize":{"betMultiplier":"1","multiplier":"1","name":"Total","pay":"0","payName":"","position":"0","symbolCount":"0","totalPay":"0","ways":"0"}}],"OutcomeDetail":{"TransactionId":"A10M@-15439533032755","Stage":"BaseGame","NextStage":"BaseGame","Balance":"5918261","GameStatus":"Start","Settled":"300","Pending":"0","Payout":"0"},"PopulationOutcome":[{"name":"CountryPicker.Picks","stage":"CountryPicker","Entry":[{"name":"L0C0R0","stripIndex":"0","Cell":"trigger,SubPicker1"},{"name":"L0C1R0","stripIndex":"1","Cell":"trigger,SubPicker2"},{"name":"L0C2R0","stripIndex":"2","Cell":"trigger,SubPicker3"}]},{"name":"OneToRule","stage":"OneToRule","Entry":[{"name":"L0C0R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C1R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C2R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C3R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C4R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C5R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C6R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C7R0","stripIndex":"0","Cell":"trigger,Nope"},{"name":"L0C8R0","stripIndex":"0","Cell":"trigger,Nope"}]},{"name":"BaseGame.JackpotReels","stage":"BaseGame","Entry":[{"name":"Reel0","stripIndex":"163","Cell":["s08","s09","s10","s02"]},{"name":"Reel1","stripIndex":"193","Cell":["s02","s07","s10","j01"]},{"name":"Reel2","stripIndex":"573","Cell":["s02","s08","b01","s09"]},{"name":"Reel3","stripIndex":"48","Cell":["s07","s08","s03","s06"]},{"name":"Reel4","stripIndex":"91","Cell":["s07","s08","s04","s09"]}]},{"name":"BonusPicker.Picks","stage":"BonusPicker","Entry":[{"name":"L0C0R0","stripIndex":"0","Cell":"trigger,CountryPicker"},{"name":"L0C1R0","stripIndex":"1","Cell":"spins,5,trigger,FreeSpin"}]},{"name":"BaseGame.Reels","stage":"BaseGame","Entry":[{"name":"Reel0","stripIndex":"163","Cell":["s08","s09","s10","s02"]},{"name":"Reel1","stripIndex":"193","Cell":["s02","s07","s10","s20"]},{"name":"Reel2","stripIndex":"573","Cell":["s02","s08","b01","s09"]},{"name":"Reel3","stripIndex":"48","Cell":["s07","s08","s03","s06"]},{"name":"Reel4","stripIndex":"91","Cell":["s07","s08","s04","s09"]}]},{"name":"FreeSpin.Reels","stage":"FreeSpin","Entry":[{"name":"Reel0","stripIndex":"1","Cell":["s01","s01","s06","s10"]},{"name":"Reel1","stripIndex":"1","Cell":["s04","s07","s09","s02"]},{"name":"Reel2","stripIndex":"1","Cell":["w01","w01","w01","s06"]},{"name":"Reel3","stripIndex":"1","Cell":["b01","s05","s07","w01"]},{"name":"Reel4","stripIndex":"1","Cell":["s06","s03","s03","s08"]}]}]}}
```

my filter looks like (i've tried this many different ways and having no luck)

```auto
filter {
  mutate {
    id => "cell->CellArray"
    gsub => ["message", "Cell:\"\[", 'CellArray:"[']
  }
  json { source => "message" }
}
```

I thought if i could rename the Cell to CellArray when its an array then i would get rid of the elasticsearch mapping issue.

```auto
Jan 4 00:55:52 logstash02 logstash: [2019-01-04T00:55:52,751][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"test-rgs-spin-2019-01-01", :_type=>"doc", :routing=>nil}, #<LogStash::Event:0x7d4277f6>], :response=>{"index"=>{"_index"=>"test-rgs-spin-2019-01-01", "_type"=>"doc", "_id"=>"MYpbFmgBNTQoEHRS-DU7", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [rgsResponseSummay.PopulationOutcome.Entry.Cell] of type [text]", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:1126"}}}}}
```

---

<div class="post-metadata">

**Author:** ![Mark\_Bassett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_bassett/32/45353_2.png) [@Mark\_Bassett](https://discuss.elastic.co/u/Mark_Bassett)\
**Post date:** [January 4, 2019, 7:13pm UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/2 "2019-01-04T19:13:40Z")

</div>

The gsub compiles but it is not changing the source data, i still see events with Cell not CellArray field.

---

<div class="post-metadata">

**Author:** ![Mark\_Bassett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_bassett/32/45353_2.png) [@Mark\_Bassett](https://discuss.elastic.co/u/Mark_Bassett)\
**Post date:** [January 11, 2019, 7:07pm UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/3 "2019-01-11T19:07:36Z")

</div>

Bump... anyone? Bueller?

---

<div class="post-metadata">

**Author:** ![Chris\_Lyons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_lyons/32/48107_2.png) [@Chris\_Lyons](https://discuss.elastic.co/u/Chris_Lyons)\
**Post date:** [January 11, 2019, 8:53pm UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/4 "2019-01-11T20:53:52Z")

</div>

Check your " position on the pattern, should fall before the :

---

<div class="post-metadata">

**Author:** ![Mark\_Bassett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_bassett/32/45353_2.png) [@Mark\_Bassett](https://discuss.elastic.co/u/Mark_Bassett)\
**Post date:** [January 11, 2019, 9:53pm UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/5 "2019-01-11T21:53:58Z")

</div>

Oh my goodness. You are correct.

I've updated the gsub, but unfortunately my root issue still exists, it now just says the field is CellArray instead of Cell.

`
filter {
  mutate {
    id => "cell->CellArray"
    gsub => ["message", "Cell\":\[", 'CellArray":[']
  }
  json { source => "message" }
`

I must have made an incorrect assumption about why the START\_OBJECT message was being generated.

`
[2019-01-11T21:50:36,359][WARN][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"test-rgs-spin-2019-01-01", :_type=>"doc", :routing=>nil}, #], :response=>{"index"=>{"_index"=>"test-rgs-spin-2019-01-01", "_type"=>"doc", "_id"=>"otLlPmgBKn8SBCQ6OUIf", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [rgsResponseSummay.PopulationOutcome.Entry.CellArray] of type [text]", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:1419"}}}}}
`

---

<div class="post-metadata">

**Author:** ![Chris\_Lyons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_lyons/32/48107_2.png) [@Chris\_Lyons](https://discuss.elastic.co/u/Chris_Lyons)\
**Post date:** [January 11, 2019, 10:09pm UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/6 "2019-01-11T22:09:24Z")

</div>

Might need to start a new index or delete your existing to ensure the type matches.

---

<div class="post-metadata">

**Author:** ![Mark\_Bassett](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_bassett/32/45353_2.png) [@Mark\_Bassett](https://discuss.elastic.co/u/Mark_Bassett)\
**Post date:** [January 11, 2019, 10:36pm UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/7 "2019-01-11T22:36:49Z")

</div>

Got it working!! I had to update my mapping to say it is an object and not searchable. With it set to an object and still searchable I ran into another this same issue [https://github.com/elastic/elasticsearch/issues/12366](https://github.com/elastic/elasticsearch/issues/12366)

Workaround/Fix in their thread fixed me as well.

`
"PopulationOutcome" : {
                "properties" : {
                  "Entry" : {
                    "properties" : {
                      "Cell" : {
                        "type" : "text",
                        "fields" : {
                          "keyword" : {
                            "type" : "keyword",
                            "ignore_above" : 256
                          }
                        }
                      },
                      "CellArray" : {
                        "type" : "object",
                        "enabled" : "false"
                      },
`

@Chris_Lyons Thank you for the eagle eye on the regex. I can't believe I missed that and I had several people looking at it lol!!

---

<div class="post-metadata">

**Author:** ![Chris\_Lyons](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chris_lyons/32/48107_2.png) [@Chris\_Lyons](https://discuss.elastic.co/u/Chris_Lyons)\
**Post date:** [January 12, 2019, 12:16am UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/8 "2019-01-12T00:16:29Z")

</div>

Happy you got it working! When you have to deal with escape characters sometimes things get lost in the mix....🙂

---

<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 9, 2019, 12:16am UTC](https://discuss.elastic.co/t/cant-get-text-on-start-object/162881/9 "2019-02-09T00:16:33Z")

</div>

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