-
-
Save schmichael/131e3a16251e75abd637eed498015ee8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Create an index with a single nested field "foo" | |
echo -n "Deleting... " | |
curl -XDELETE localhost:9200/testmissing | |
echo "" | |
echo -n "Creating... " | |
curl -XPOST localhost:9200/testmissing -d '{ | |
"settings": { | |
"number_of_shards": 1 | |
}, | |
"mappings": { | |
"test1": { | |
"properties": { | |
"abc": { | |
"type": "string", | |
"index": "not_analyzed" | |
}, | |
"foo": { | |
"type": "nested", | |
"dynamic": "false", | |
"properties": { | |
"k": { | |
"type": "string" | |
}, | |
"v": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
} | |
} | |
}' | |
echo "" | |
# Add a single document with a "foo" | |
curl -XPUT -d '{"foo": [ | |
{"k": "k1", "v": "v1"}, | |
{"k": "k2", "v": "v2"}, | |
{"k": "k3", "v": "v3"} | |
]}' localhost:9200/testmissing/test1/doc1?pretty | |
# Add a second document without a "foo" | |
curl -XPUT -d '{"abc": "123"}' localhost:9200/testmissing/test1/doc2?pretty | |
echo -n "Refreshing... " | |
curl -XPOST localhost:9200/testmissing/_refresh?pretty | |
echo "" | |
# Search and do a Missing aggregation on foo | |
curl -XPOST -d '{ | |
"aggs": { | |
"foomissing": { | |
"missing": { | |
"field": "foo" | |
} | |
}, | |
"nestedmissing": { | |
"nested": {"path": "foo"}, | |
"aggs": { "innernestedmissing": { "missing": {"field": "foo"} } } | |
} | |
} | |
}' 'localhost:9200/testmissing/_search?pretty' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment