# More than 1 level of indentation in index

**URL:** <https://discuss.elastic.co/t/more-than-1-level-of-indentation-in-index/7460>\
**Category:** Elasticsearch\
**Created:** [April 25, 2012, 8:00am UTC](https://discuss.elastic.co/t/more-than-1-level-of-indentation-in-index/7460 "2012-04-25T08:00:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerome](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@Jerome](https://discuss.elastic.co/u/Jerome)\
**Post date:** [April 25, 2012, 8:00am UTC](https://discuss.elastic.co/t/more-than-1-level-of-indentation-in-index/7460/1 "2012-04-25T08:00:16Z")

</div>

Hi,

I have a file with 2 level of indentation :  
PRIMARY\_TAG  
TAG : value

and i know that ES have just one level :  
TAG : value

Is there a way to index of 2 or more levels.

Thanks, Jerome

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 25, 2012, 2:06pm UTC](https://discuss.elastic.co/t/more-than-1-level-of-indentation-in-index/7460/2 "2012-04-25T14:06:23Z")

</div>

Elasticsearch, actually, supports multiple levels. Take a look at Object  
Type [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/object-type.html)

On Wednesday, April 25, 2012 4:00:16 AM UTC-4, Jérome wrote:

> Hi,
> 
> I have a file with 2 level of indentation :  
> PRIMARY\_TAG  
> TAG : value
> 
> and i know that ES have just one level :  
> TAG : value
> 
> Is there a way to index of 2 or more levels.
> 
> Thanks, Jerome

---

<div class="post-metadata">

**Author:** ![Jerome](https://avatars.discourse-cdn.com/v4/letter/j/a587f6/32.png) [@Jerome](https://discuss.elastic.co/u/Jerome)\
**Post date:** [April 26, 2012, 10:17am UTC](https://discuss.elastic.co/t/more-than-1-level-of-indentation-in-index/7460/3 "2012-04-26T10:17:46Z")

</div>

Thx,

I have two question now :

For index with multiple levels, in PERL ?

$result = $es-\>index(  
index =\> $index,  
type =\> $type,  
id =\> $i,  
data =\> {  
id =\> {

ACC =\> $num\_acc,  
DESC =\> $desc,  
VERSION =\> $version,  
GI =\> $gi  
}  
ORGANISME =\> $espece,  
CLASSIFICATION =\> $classification,  
SEQUENCE =\> $seq  
},  
);

And my second question, more important for me is :

In PERL, (with the example above), what type is $result ?  
It's not JSON because i can't decode it with "decode\_json($result)".

I want print in a file the result of the operation.  
When i'm doing a get with pretty=true i've all data on a single line :

{  
"\_index" : "z",  
"\_type" : "z",  
"\_id" : "1",  
"\_version" : 98,  
"exists" : true, "\_source" :  
{"SEQUENCE":"CGCCTCCCCAATACCTAATAAGGCATGCGAAATGTTCTCATGAACTACCCCACAACACGCCTAAAACTCAAAACACCCAAAAATATCTCCTCCAATGTCCTGAAACATGAACCCAAAAAGAGACCCACAATAAACTCGTGACTTGTCCCCTCAAAAAAAAAA","CLASSIFICATION":"Eukaryota-

> Metazoa-\>Chordata-\>Craniata-\>Vertebrata-\>Euteleostomi-\>Mammalia-  
> Eutheria-\>Euarchontoglires-\>Primates-\>Haplorrhini-\>Catarrhini-  
> Hominidae-\>Homo-\>Homo sapiens","DESC":"Homo sapiens FXYD domain  
> containing ion transport regulator 3 (FXYD3), transcript variant 8,  
> mRNA.","ACC":"NM\_001136012","ORGANISME":"Homo  
> sapiens","GI":"209862818","VERSION":"1","keyword":"","comment":"REVIEWED  
> REFSEQ...

I cut it because so looong but i don't understand. How can i have the  
result with  
SEQUENCE : ...  
CLASSIFICATION : ...  
...  
and not in a single line ?  
On 25 avr, 16:06, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:

> Elasticsearch, actually, supports multiple levels. Take a look at Object  
> Typehttp://www.elasticsearch.org/guide/reference/mapping/object-type.html
> 
> On Wednesday, April 25, 2012 4:00:16 AM UTC-4, Jérome wrote:
> 
> > Hi,
> 
> > I have a file with 2 level of indentation :  
> > PRIMARY\_TAG  
> > TAG : value
> 
> > and i know that ES have just one level :  
> > TAG : value
> 
> > Is there a way to index of 2 or more levels.
> 
> > Thanks, Jerome

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 26, 2012, 5:10pm UTC](https://discuss.elastic.co/t/more-than-1-level-of-indentation-in-index/7460/4 "2012-04-26T17:10:58Z")

</div>

pretty=true doesn't format source. Data in the \_source field is always  
returned as it was indexed. If you want a nicely formated source, just pass  
entire response though a json formatter. I typically pipe it through python  
-mjson.tool

On Thursday, April 26, 2012 6:17:46 AM UTC-4, Jérome wrote:

> Thx,
> 
> I have two question now :
> 
> For index with multiple levels, in PERL ?
> 
> $result = $es-\>index(  
> index =\> $index,
> 
> ```
> type => $type, 
> 
> id => $i, 
> 
> data => { 
> id 
> 
> ```
> 
> =\> {
> 
> ACC =\> $num\_acc,  
> DESC =\>  
> $desc,  
> VERSION  
> =\> $version,  
> GI =\>  
> $gi  
> }  
> ORGANISME =\>  
> $espece,  
> CLASSIFICATION =\>  
> $classification,  
> SEQUENCE =\>  
> $seq  
> },  
> );
> 
> And my second question, more important for me is :
> 
> In PERL, (with the example above), what type is $result ?  
> It's not JSON because i can't decode it with "decode\_json($result)".
> 
> I want print in a file the result of the operation.  
> When i'm doing a get with pretty=true i've all data on a single line :
> 
> {  
> "\_index" : "z",  
> "\_type" : "z",  
> "\_id" : "1",  
> "\_version" : 98,  
> "exists" : true, "\_source" :  
> {"SEQUENCE":"CGCCTCCCCAATACCTAATAAGGCATGCGAAATGTTCTCATGAACTACCCCACAACACGCCTAAAACTCAAAACACCCAAAAATATCTCCTCCAATGTCCTGAAACATGAACCCAAAAAGAGACCCACAATAAACTCGTGACTTGTCCCCTCAAAAAAAAAA","CLASSIFICATION":"Eukaryota-
> 
> > Metazoa-\>Chordata-\>Craniata-\>Vertebrata-\>Euteleostomi-\>Mammalia-  
> > Eutheria-\>Euarchontoglires-\>Primates-\>Haplorrhini-\>Catarrhini-  
> > Hominidae-\>Homo-\>Homo sapiens","DESC":"Homo sapiens FXYD domain  
> > containing ion transport regulator 3 (FXYD3), transcript variant 8,  
> > mRNA.","ACC":"NM\_001136012","ORGANISME":"Homo  
> > sapiens","GI":"209862818","VERSION":"1","keyword":"","comment":"REVIEWED  
> > REFSEQ...
> 
> I cut it because so looong but i don't understand. How can i have the  
> result with  
> SEQUENCE : ...  
> CLASSIFICATION : ...  
> ...  
> and not in a single line ?  
> On 25 avr, 16:06, Igor Motov [imo...@gmail.com](mailto:imo...@gmail.com) wrote:
> 
> > Elasticsearch, actually, supports multiple levels. Take a look at Object  
> > Typehttp://  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/object-type.html)
> > 
> > On Wednesday, April 25, 2012 4:00:16 AM UTC-4, Jérome wrote:
> > 
> > > Hi,
> > 
> > > I have a file with 2 level of indentation :  
> > > PRIMARY\_TAG  
> > > TAG : value
> > 
> > > and i know that ES have just one level :  
> > > TAG : value
> > 
> > > Is there a way to index of 2 or more levels.
> > 
> > > Thanks, Jerome

---

<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 6, 2017, 3:31am UTC](https://discuss.elastic.co/t/more-than-1-level-of-indentation-in-index/7460/5 "2017-07-06T03:31:00Z")

</div>


