Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Given this index and mapping:
- POST /test
- {
- "settings" : {
- "number_of_shards" : 1
- },
- "mappings" : {
- "testdoc" : {
- "properties" : {
- "META": {
- "type": "nested",
- "properties": {
- "scheme_name": {
- "type": "string",
- "index": "no"
- },
- "scheme_data": {
- "type": "nested",
- "properties": {
- "column_name": {
- "type": "string",
- "index": "no" },
- "value": {
- "type": "string"}}}}}}}}}
- # And this test data:
- POST /test/testdoc
- {
- "path": "/matt/matt-pics",
- "file": "dog.jpg",
- "mime_type": "image/jpeg",
- "META": [
- {
- "scheme_name": "Pseudo_EXIF_Scheme",
- "scheme_data": [
- {
- "value": "Nikon",
- "column_name": "CAMERA_MANUFACTURER"
- },
- {
- "value": "D80",
- "column_name": "CAMERA_MODEL"
- }
- ]
- }
- ]
- }
- POST /test/testdoc
- {
- "path": "/matt/matt-music",
- "file": "song.mp3",
- "mime_type": "audio/mp3",
- "META": [
- {
- "scheme_name": "Pseudo_MP3_Scheme",
- "scheme_data": [
- {
- "value": "Foo",
- "column_name": "ARTIST"
- },
- {
- "value": "Bar",
- "column_name": "SONGTITLE"
- }
- ]
- }
- ]
- }
- # I want to be able to do terms / bucket aggregations to get something like this (buckets over META.scheme_name
- #<snip>
- "buckets": [
- {
- "key": "Pseudo_MP3_Scheme",
- "doc_count": 1
- },
- {
- "key": "Pseudo_EXIF_Scheme",
- "doc_count": 1
- }
- ]
- #<snip>
- #and also over specific values in the nested doc eg for 'Artist'
- "buckets": [
- {
- "key": "Foo",
- "doc_count": 1
- }
- ]
- #But I'm totally stuck on the syntax for aggregating nested documents like this and have tried for several hours without any success.
- #Thanks in advance for your help!
Add Comment
Please, Sign In to add comment