Problem with highlighting in has_child query

I am unable to get highlighting results when querying a field of type
attachment in a child document using the has_child query. However I
am able to get the highlighting results if I query directly against
the child document.

Is this supported, or am I doing something wrong?

The child document is of type "contentFiles" with a field called
"file" of type attachment (for pdf file processed by the mapper-
attachments). This query successfully returns highlight elements:

curl -XGET 'http://localhost:9201/foo_acme/contentFiles/_search' -d
'{"query":{"field":{"file" : "Account"}},"highlight":{"fields":
{"file": {}}}}'

However when I try to query via the parent type "content" using a
has_child query, I get the search results but I don't get the
highlight elements:

curl -XGET 'http://localhost:9201/foo_acme/content/_search' -d
'{"query": {"has_child":{"type":"contentFiles", "query":{"field":
{"file" : "Account"}},"highlight":{"fields":{"file":{}}}}}}'

I'm using elasticsearch version 0.16.2.

For completeness, here is my mapping for the contentFiles type, but I
think the mapping is ok, since my first query works:
{
"contentFiles": {
"_source" : {
"enabled" : false
},
"_parent": {
"type" : "content"
},
"properties" : {
"file" : {
"type" : "attachment",
"fields" : {
"file" : {"store" : "yes",
"term_vector" : "with_positions_offsets"}
}
}
}
}
}

Thanks!
Lar

You can't do highlighting on the content of a child document when using has_child query, that idea for that is to just match and return the parent docs, and those will be the ones that will be highlighted... .

On Wednesday, June 15, 2011 at 11:00 PM, lmader wrote:

I am unable to get highlighting results when querying a field of type
attachment in a child document using the has_child query. However I
am able to get the highlighting results if I query directly against
the child document.

Is this supported, or am I doing something wrong?

The child document is of type "contentFiles" with a field called
"file" of type attachment (for pdf file processed by the mapper-
attachments). This query successfully returns highlight elements:

curl -XGET 'http://localhost:9201/foo_acme/contentFiles/_search' -d
'{"query":{"field":{"file" : "Account"}},"highlight":{"fields":
{"file": {}}}}'

However when I try to query via the parent type "content" using a
has_child query, I get the search results but I don't get the
highlight elements:

curl -XGET 'http://localhost:9201/foo_acme/content/_search' -d
'{"query": {"has_child":{"type":"contentFiles", "query":{"field":
{"file" : "Account"}},"highlight":{"fields":{"file":{}}}}}}'

I'm using elasticsearch version 0.16.2.

For completeness, here is my mapping for the contentFiles type, but I
think the mapping is ok, since my first query works:
{
"contentFiles": {
"_source" : {
"enabled" : false
},
"_parent": {
"type" : "content"
},
"properties" : {
"file" : {
"type" : "attachment",
"fields" : {
"file" : {"store" : "yes",
"term_vector" : "with_positions_offsets"}
}
}
}
}
}

Thanks!
Lar

Ok, thank you for the info!

Is this a feature that could be supported in the future? We have a
monstrous query that goes against the parent and child docs, and it
would be very convenient if it could do the highlighting in the
has_child part as well.

Cheers,
Lar

Good question... . Nothing planned, mainly since implementation wise its quite heavy to do it (if implemented). Need to spend some time thinking about it properly.

On Friday, June 17, 2011 at 2:43 AM, lmader wrote:

Ok, thank you for the info!

Is this a feature that could be supported in the future? We have a
monstrous query that goes against the parent and child docs, and it
would be very convenient if it could do the highlighting in the
has_child part as well.

Cheers,
Lar

Hi. Has this been implemented or is there any workaround? As my documents and subdocuments are really big, I'd really like to avoid nested objects/queries.

Thanks!