Three-level parent/child-mapping: Query the second level via its childs


(Felix S.) #1

Hi!

I'm trying to build an index schema with three levels, lets call them a, b
and c, which are joined via parent-child-relations. The 'a' type is parent
of the 'b' type, which again is parent of the 'c' type. Querying the top
level, the 'a' type, via its 'b' children works without issues. However,
when I try to query the middle 'b' level via its 'c' children, i.e. query
/myindex/b/ with a has_child() query for type 'c' with some query that
matches one of the 'c' documents in my index, I always get zero results. I
tested this against 0.19.1 and the latest version from git, both via the
Java API and via curl'ed json requests. I'm attaching a shell script with
my curl requests, I hope I didnt overlook any errors in there, but I
quadruple checked it and couldn't find any.

Regards,
Felix


Life without mapping types (6.0)
(Shay Banon) #2

When you index mult level mappings, for the third level you need to make
sure to set teh routing value to the top most doc id, otherwise, it will be
routed wrongly. For example, index c with routing of a1. See if it helps...

On Fri, Mar 30, 2012 at 9:12 PM, Felix S. f.sappelt@clueda.com wrote:

Hi!

I'm trying to build an index schema with three levels, lets call them a, b
and c, which are joined via parent-child-relations. The 'a' type is parent
of the 'b' type, which again is parent of the 'c' type. Querying the top
level, the 'a' type, via its 'b' children works without issues. However,
when I try to query the middle 'b' level via its 'c' children, i.e. query
/myindex/b/ with a has_child() query for type 'c' with some query that
matches one of the 'c' documents in my index, I always get zero results. I
tested this against 0.19.1 and the latest version from git, both via the
Java API and via curl'ed json requests. I'm attaching a shell script with
my curl requests, I hope I didnt overlook any errors in there, but I
quadruple checked it and couldn't find any.

Regards,
Felix


(Felix S.) #3

Yes, that works. Thanks!

Am Dienstag, 3. April 2012 15:41:04 UTC+2 schrieb kimchy:

When you index mult level mappings, for the third level you need to make
sure to set teh routing value to the top most doc id, otherwise, it will be
routed wrongly. For example, index c with routing of a1. See if it helps...

On Fri, Mar 30, 2012 at 9:12 PM, Felix S. f.sappelt@clueda.com wrote:

Hi!

I'm trying to build an index schema with three levels, lets call them a,
b and c, which are joined via parent-child-relations. The 'a' type is
parent of the 'b' type, which again is parent of the 'c' type. Querying the
top level, the 'a' type, via its 'b' children works without issues.
However, when I try to query the middle 'b' level via its 'c' children,
i.e. query /myindex/b/ with a has_child() query for type 'c' with some
query that matches one of the 'c' documents in my index, I always get zero
results. I tested this against 0.19.1 and the latest version from git, both
via the Java API and via curl'ed json requests. I'm attaching a shell
script with my curl requests, I hope I didnt overlook any errors in there,
but I quadruple checked it and couldn't find any.

Regards,
Felix


(system) #4