More than 1 level of indentation in index


(Jérome) #1

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


(Igor Motov) #2

Elasticsearch, actually, supports multiple levels. Take a look at Object
Type 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


(Jérome) #3

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 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


(Igor Motov) #4

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 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


(system) #5