# How is Elasticsearch-data represented in Lucene

**URL:** <https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839>\
**Category:** Elasticsearch\
**Created:** [June 23, 2016, 10:36pm UTC](https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839 "2016-06-23T22:36:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chocomuesli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chocomuesli/32/4152_2.png) [@chocomuesli](https://discuss.elastic.co/u/chocomuesli)\
**Post date:** [June 23, 2016, 10:36pm UTC](https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839/1 "2016-06-23T22:36:26Z")

</div>

Hi guys,

as I learnt, Elasticsearch is based on Apache Lucene as its data is distributed in shards (due to configuration), with each shard being a Lucene index. Lucene stores key-values pairs in an inverted index, while Elasticsearch does this using JSON (please correct me, if I'm wrong).

I tried to understand by browsing through some Elasticsearch shards using [Luke](https://github.com/DmitryKey/luke), but I can't grasp how Elasticsearch documents are represented in Lucene. Please help me understand, since I've found no information in literature or online. Any hints, corrections and answers are welcome! 🙂

Cheers, Dominik

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 23, 2016, 10:44pm UTC](https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839/2 "2016-06-23T22:44:35Z")

</div>

A document is stored as json.

We also store the traditional inverted index of the documents for the search aspects, as well as a columnar representation for things like doc values that are used in aggregations.

---

<div class="post-metadata">

**Author:** ![chocomuesli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chocomuesli/32/4152_2.png) [@chocomuesli](https://discuss.elastic.co/u/chocomuesli)\
**Post date:** [June 24, 2016, 5:38am UTC](https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839/3 "2016-06-24T05:38:47Z")

</div>

Hello Mark,

many thanks for your answer! 😀 Does the columnar representation include nested-fields? My biggest problem is, understanding how cases like these are represented - since Lucene comes with key-value pairs.

---

<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:** [June 24, 2016, 6:04am UTC](https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839/4 "2016-06-24T06:04:30Z")

</div>

Everything is flatten unless you define the nested type for a given array. In that case every single inner object will be index as a Lucene doc.

---

<div class="post-metadata">

**Author:** ![chocomuesli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chocomuesli/32/4152_2.png) [@chocomuesli](https://discuss.elastic.co/u/chocomuesli)\
**Post date:** [June 24, 2016, 9:51am UTC](https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839/5 "2016-06-24T09:51:28Z")

</div>

Solved! Thank you, Mark and David!

---

<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:** [July 5, 2017, 10:40pm UTC](https://discuss.elastic.co/t/how-is-elasticsearch-data-represented-in-lucene/53839/6 "2017-07-05T22:40:48Z")

</div>


