"Inherits" parents properties (hierarchy)


(Manuel Vacelet) #1

Hello,

I'm quite a newbie in ES world so please forgive me if I write something
stupid.

I have data organized in a hierarchical way:
.
-- [id=1 title="build a car" release="1.0"]-- [id=2 title="find the wheels" ]

When users look for "1.0" and "wheels" the should get document n°2
I tried to use the "parent" relationship (when I create document n°2, I
tell ES that document 1 is it's parent) but I get no results when I
querying like
{
"query": {
"bool": {
"must": [
{
"term": {
"release": "1.0"
}
},
{
"term": {
"title": "wheels"
}
}
]
}
}
}

How can I solve my problem ?

Thanks,
Manuel

--


(David Pilato) #2

I think that nested docs fits better to your use case. See:
http://www.elasticsearch.org/guide/reference/mapping/nested-type.html
http://www.elasticsearch.org/guide/reference/mapping/nested-type.html

Have a look also at
http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query.html
http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query.html
and
http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query.html
http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query.html

I think (not sure) it can help here.

My 2 cents

David.

Le 9 octobre 2012 à 15:45, Manuel Vacelet manuel.vacelet@gmail.com a écrit :

Hello,

I'm quite a newbie in ES world so please forgive me if I write something
stupid.

I have data organized in a hierarchical way:
.
-- [id=1 title="build a car" release="1.0"]-- [id=2 title="find the wheels" ]

When users look for "1.0" and "wheels" the should get document n°2
I tried to use the "parent" relationship (when I create document n°2, I tell
ES that document 1 is it's parent) but I get no results when I querying like
{
"query": {
"bool": {
"must": [
{
"term": {
"release": "1.0"
}
},
{
"term": {
"title": " wheels"
}
}
]
}
}
}

How can I solve my problem ?

Thanks,
Manuel

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--


(system) #3