Skip to content

Instantly share code, notes, and snippets.

@johtani
Created July 20, 2020 04:17
Show Gist options
  • Save johtani/0a27539fb87dbb4c4cf76d73e799c609 to your computer and use it in GitHub Desktop.
Save johtani/0a27539fb87dbb4c4cf76d73e799c609 to your computer and use it in GitHub Desktop.
joinで子供をハイライト
PUT join_highlight
{
"mappings": {
"properties": {
"my_id": {
"type": "keyword"
},
"my_join_field": {
"type": "join",
"relations": {
"question": "answer"
}
}
}
}
}
PUT join_highlight/_doc/1?refresh
{
"my_id": "1",
"text": "This is a question",
"my_join_field": {
"name": "question"
}
}
PUT join_highlight/_doc/2?refresh
{
"my_id": "2",
"text": "This is another question",
"my_join_field": {
"name": "question"
}
}
PUT join_highlight/_doc/3?routing=1&refresh
{
"my_id": "3",
"text": "This is an answer",
"my_join_field": {
"name": "answer",
"parent": "1"
}
}
PUT join_highlight/_doc/4?routing=1&refresh
{
"my_id": "4",
"text": "This is another answer",
"my_join_field": {
"name": "answer",
"parent": "1"
}
}
GET join_highlight/_search
{
"query": {
"has_child": {
"type": "answer",
"query": {
"match": {
"text": "answer"
}
},
"inner_hits": {
"highlight": {
"fields": {
"text": {}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment