Skip to content

Instantly share code, notes, and snippets.

@jtibshirani
Last active August 29, 2015 14:02
Show Gist options
  • Save jtibshirani/3f6baeb7f306e92ca44e to your computer and use it in GitHub Desktop.
Save jtibshirani/3f6baeb7f306e92ca44e to your computer and use it in GitHub Desktop.
highlighting doesn't work for nested queries, even with _source enabled
curl -XDELETE 'localhost:9200/test'
curl -XPOST 'localhost:9200/test' -d '
{
"settings": {
"number_of_replicas": 0,
"number_of_shards": 1
},
"mappings": {
"author": {
"properties": {
"name": { "type": "string" },
"gender": { "type": "string" },
"book": {
"type" : "nested",
"properties": {
"title": { "type": "string" }
}
}
}
}
}
}'
curl -XPOST 'localhost:9200/test/author/1?refresh' -d '
{
"name": "simone de beauvoir",
"gender": "female",
"book": {
"title": "the ethics of ambiguity"
}
}'
# fails to produce highlights
curl -XPOST 'localhost:9200/test/author/_search?pretty' -d '
{
"query": {
"nested": {
"query": {
"match": { "book.title": "ethics" }
},
"path": "book"
}
},
"highlight": {
"fields": {
"book.title" : {}
}
}
}'
# also fails
curl -XPOST 'localhost:9200/test/author/_search?pretty' -d '
{
"query": {
"match": { "name": "simone" }
},
"highlight": {
"fields": {
"book.title" : {
"highlight_query": {
"nested": {
"query": {
"match": { "book.title": "ethics" }
},
"path": "book"
}
}
}
}
}
}'
# succeeds
curl -XPOST 'localhost:9200/test/author/_search?pretty' -d '
{
"query": {
"match": { "name": "simone" }
},
"highlight": {
"fields": {
"book.title" : {
"highlight_query": {
"match": { "book.title": "ethics" }
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment