# Add dictionary to index

**URL:** <https://discuss.elastic.co/t/add-dictionary-to-index/92415>\
**Category:** Elasticsearch\
**Created:** [July 10, 2017, 7:08am UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415 "2017-07-10T07:08:52Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![avivc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avivc/32/16501_2.png) [@avivc](https://discuss.elastic.co/u/avivc)\
**Post date:** [July 13, 2017, 6:14am UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/23 "2017-07-13T06:14:47Z")

</div>

> [@Mark\_Harwood](#):
>
> Because it's an array not a dict?

@Mark_Harwood are you asking or saying?  
Tnx

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 13, 2017, 6:55am UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/24 "2017-07-13T06:55:56Z")

</div>

Just print 'lbapi\_Response\_Data'

Tell me if the output starts with [ or {

---

<div class="post-metadata">

**Author:** ![avivc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avivc/32/16501_2.png) [@avivc](https://discuss.elastic.co/u/avivc)\
**Post date:** [July 15, 2017, 6:00pm UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/25 "2017-07-15T18:00:17Z")

</div>

@Mark_Harwood  
It starts with `[` and than multiple objects that starts with `{`

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 16, 2017, 3:20pm UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/26 "2017-07-16T15:20:14Z")

</div>

So that's an array not a dictionary and therefore not a valid Json document  
for elasticsearch.

---

<div class="post-metadata">

**Author:** ![avivc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avivc/32/16501_2.png) [@avivc](https://discuss.elastic.co/u/avivc)\
**Post date:** [July 16, 2017, 3:37pm UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/27 "2017-07-16T15:37:38Z")

</div>

Hi @Mark_Harwood  
So data convention is necessary to solve this issue? Will I be able to push a whole dictionary into my index without disassembly it to objects?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 16, 2017, 3:47pm UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/28 "2017-07-16T15:47:12Z")

</div>

> [@avivc](#):
>
> Will I be able to push a whole dictionary into my index without disassembly it to objects?

Yes, with the caveats that I referenced in my first comment on this thread.

---

<div class="post-metadata">

**Author:** ![avivc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avivc/32/16501_2.png) [@avivc](https://discuss.elastic.co/u/avivc)\
**Post date:** [July 17, 2017, 8:21am UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/29 "2017-07-17T08:21:51Z")

</div>

I've removed the `[]` but in closer look I think I know what's the problem  
My data structure build as follows:

> '{  
> u'key':value, u'key':value, u'key':value, u'key':value, u'key':value, u'key':value  
> }'

Elastic log file:  
`Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('u' (code 117)): was expecting double-quote to start field name org.elasticsearch.index.mapper.MapperParsingException: failed to parse`

The `u` prefix comes from the API I'm using. Trying to convert it is more relevant to data structure. I assume that it'll be more proper & efficient to handle it with rational DB

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [July 17, 2017, 9:29am UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/30 "2017-07-17T09:29:16Z")

</div>

If you need further help with this you will need to supply example data+code we can actually run to reproduce any issues. It took us 7 days to figure out you had an array not a dictionary and if you can supply simplified reproducible examples we can get to answers faster.

---

<div class="post-metadata">

**Author:** ![avivc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avivc/32/16501_2.png) [@avivc](https://discuss.elastic.co/u/avivc)\
**Post date:** [July 17, 2017, 2:22pm UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/31 "2017-07-17T14:22:38Z")

</div>

I understand  
I'll check in if I can export data to resolve this issue

@Mark_Harwood thank you very much for the effort you put trying to solve this thread

---

<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:** [August 14, 2017, 2:22pm UTC](https://discuss.elastic.co/t/add-dictionary-to-index/92415/32 "2017-08-14T14:22:41Z")

</div>

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

[Previous page](https://discuss.elastic.co/t/add-dictionary-to-index/92415.md?page=1)
