Search on top_children and parent fields


(Maik Broxterman) #1

I'm using top_children for finding parent documents by the content of the
child. This works good for me, but I want to be able to search for a field
of the parent too, in the same query. I'm thinking about something like
this:

curl -XPOST 'localhost:9200/default/topic/_search?pretty=true' -d '
{
"query": {
"top_children" : {
"type": "post",
"query": {
"text" : {
"content" : {
"query" : "parent child",
"operator" : "and",
"fuzziness": 0.5
}
}
},
"incremental_factor":5
},
"text": {
"title" : {
"query" : "parent child",
"operator" : "and"
}
}
}'

but it geves me an error:

Parse Failure [No parser for element [title]]

while something like:

curl -XPOST 'localhost:9200/default/topic/_search?pretty=true' -d '
{
"query": {
"text": {
"title" : {
"query" : "parent child",
"operator" : "and"
}
}
}'

works (so without the top children).

Title is a field of topic and content a field of post.

So: how do I combine top children with a search on the parents' own fields?

Thanks in advance.

--


(Clinton Gormley) #2

Hi Maik

curl -XPOST 'localhost:9200/default/topic/_search?pretty=true' -d '
{
"query": {
"top_children" : {
},
"text": {
},
}'

You can't have two top level queries. You need to nest you top_children
and text queries in a bool query

clint

--


(Maik Broxterman) #3

Aah, nice.

Cool, thanks! It seems it works now.

On Thursday, August 23, 2012 12:53:45 PM UTC+2, Clinton Gormley wrote:

Hi Maik

curl -XPOST 'localhost:9200/default/topic/_search?pretty=true' -d '
{
"query": {
"top_children" : {
},
"text": {
},
}'

You can't have two top level queries. You need to nest you top_children
and text queries in a bool query

clint

--


(system) #4