Skip to content

Instantly share code, notes, and snippets.

@djptek
Last active April 14, 2021 17:10
Show Gist options
  • Save djptek/06370bcfdb4b39921765cb108e1aad32 to your computer and use it in GitHub Desktop.
Save djptek/06370bcfdb4b39921765cb108e1aad32 to your computer and use it in GitHub Desktop.
nested mapping within nested mapping for Elasticsearch
PUT nested_nested_test
{
"mappings": {
"properties": {
"1": {
"type": "nested",
"properties": {
"2": {
"type": "nested",
"properties": {
"a": {
"type": "boolean"
},
"b": {
"type": "boolean"
}
}
}
}
}
}
}
}
PUT nested_nested_test/_doc/1
{
"1": [
{
"2": [
{
"a": true,
"b": false
}
]
}
]
}
# should get a hit
GET nested_nested_test/_search
{
"query": {
"nested": {
"path": "1",
"query": {
"nested": {
"path": "1.2",
"query": {
"bool": {
"must": [
{
"match": {
"1.2.a": true
}
},
{
"match": {
"1.2.b": false
}
}
]
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment