Created
April 14, 2015 21:51
-
-
Save timglabisch/8abc4a1403dd56ccd60f 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
PUT /material | |
{ | |
"mappings": { | |
"material": { | |
"properties": { | |
"grapevariety": { | |
"type": "string", | |
"analyzer": "keyword" | |
}, | |
"color": { | |
"type": "string", | |
"analyzer": "keyword" | |
}, | |
"winemaker": { | |
"type": "string", | |
"analyzer": "keyword" | |
}, | |
"wban": { | |
"type": "nested", | |
"properties": { | |
"wban": { | |
"type": "string", | |
"analyzer": "keyword" | |
}, | |
"price": { | |
"type": "float", | |
"analyzer": "keyword" | |
}, | |
"mailing": { | |
"type": "string", | |
"analyzer": "keyword" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
DELETE /material | |
POST /_bulk | |
{"index":{"_index":"material","_type":"material"}} | |
{"grapevariety":"Château","color":"red","winemaker":"Tim Glabisch", "wban": [{"wban": "11234", "price": 12.99}]} | |
{"index":{"_index":"material","_type":"material"}} | |
{"grapevariety":"Var","color":"red","winemaker":"w2", "wban": [{"wban": "21234", "price": 12.99, "mailing": ["foo_mailing"]}, {"wban": "22234", "price": 11.99}]} | |
{"index":{"_index":"material","_type":"material"}} | |
{"grapevariety":"Château","color":"green","winemaker":"w2", "wban": [{"wban": "31234", "price": 13.99, "mailing": ["foo_mailing", "mailing2"]}]} | |
{"index":{"_index":"material","_type":"material"}} | |
{"grapevariety":"Château2","color":"green2","winemaker":"w3", "wban": [{"wban": "41234", "price": 15.99, "mailing": ["mailing2"]}]} | |
POST /material/material/_search | |
POST /material/material/_search | |
{ | |
"fields": ["_id"], | |
"query": { | |
"nested": { | |
"path": "wban", | |
"query": { | |
"match_all": {} | |
}, | |
"inner_hits": { | |
"size": 1 | |
} | |
} | |
} | |
} | |
POST /material/material/_search | |
{ | |
"fields": ["_id"], | |
"query": { | |
"nested": { | |
"path": "wban", | |
"query": { | |
"bool": { | |
"must_not": [ | |
{ | |
"term": { | |
"mailing": { | |
"value": "foo_mailing" | |
} | |
} | |
} | |
] | |
} | |
}, | |
"inner_hits": { | |
"size": 1 | |
} | |
} | |
} | |
} | |
POST /material/material/_search | |
{ | |
"fields": ["_id"], | |
"aggs": { | |
"aggs": { | |
"filter": { | |
"match_all": {} | |
}, | |
"aggs": { | |
"aggs": { | |
"terms": { | |
"field": "grapevariety" | |
} | |
} | |
} | |
} | |
}, | |
"query": { | |
"filtered": { | |
"filter": { | |
"nested": { | |
"path": "wban", | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"bool": { | |
"should": [ | |
{ | |
"terms": { | |
"mailing": [ | |
"foo_mailing" | |
] | |
} | |
}, | |
{ | |
"filtered": { | |
"filter": { | |
"missing": { | |
"field": "mailing" | |
} | |
} | |
} | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
"inner_hits": { | |
"size": 1 | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment