Searching parent and child documents at the same time

(Alessio G) #1

Hello the title of the topic is only for catching your attention.
I've two type from a mysql river import and one index.
I've created a parent child relation between types.
Now the weird requirement: I have to make a fulltext serach on a set of data where the parent and the child are resolved.
In other words a particular word could be in the first type or in the second type but i need to do a full text search on both with only one query.
Could you help me? thanks.

(Igor Motov) #2

I fixed the title for you, it's now catchier. Who are you trying to find with this single query - parents or children?

(Alessio G) #3

Hi Igor , first of all. I want to get using a single query the parent and it's children basing on a field of the parent. It's a multi index multi type query. I've imported data from mysql using a go script that dump and use binlog. Thanks for your support.

(Igor Motov) #4

If you want to find parents, you need to use a bool query with 2 should clauses. The first clause will be simple match agains parent. The second clause will be match wrapped into has_child query agains children. If you want all children that matched each parent, you can use inner_hits

(Alessio G) #5

thanks . I was able to do the 2 should . I didn't know about inner_hits. I will study it. thanks.

(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.