# Dictionary vs Map datastructure in app-search?

**URL:** <https://discuss.elastic.co/t/dictionary-vs-map-datastructure-in-app-search/204141>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [October 17, 2019, 11:30pm UTC](https://discuss.elastic.co/t/dictionary-vs-map-datastructure-in-app-search/204141 "2019-10-17T23:30:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![teja\_sri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teja_sri/32/55614_2.png) [@teja\_sri](https://discuss.elastic.co/u/teja_sri)\
**Post date:** [October 17, 2019, 11:30pm UTC](https://discuss.elastic.co/t/dictionary-vs-map-datastructure-in-app-search/204141/1 "2019-10-17T23:30:26Z")

</div>

{  
"address\_id":1  
"residential\_address": {  
"current": "USA",  
"previous": "India"  
},  
"office\_address": {  
"current": "Okemos",  
"previous": "Bangalore"  
},  
"id": 1  
}

In the above mentioned data structure I have Map of address which internally holds map of current and previous address. What is the efficient way to index this data structure in app-search??  
can I use dictionary to efficiently save the structure(if so can anyone tell me how)?

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [October 22, 2019, 7:43pm UTC](https://discuss.elastic.co/t/dictionary-vs-map-datastructure-in-app-search/204141/2 "2019-10-22T19:43:48Z")

</div>

Hi @teja_sri,

Generally speaking, when indexing data into App Search, our recommendation is to flatten data. The flattened version of the above might be something like:

```auto
{
  "address_id": 1,
  "residential_address_current": "USA",
  "residential_address_previous": "India",
  "office_address_current": "Okemos",
  "office_address_previous": "Bangalore"
}

```

---

<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:** [November 19, 2019, 7:43pm UTC](https://discuss.elastic.co/t/dictionary-vs-map-datastructure-in-app-search/204141/3 "2019-11-19T19:43:50Z")

</div>

Closed on November 19, 2019, 7:43pm UTC

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