Created
February 17, 2017 13:24
-
-
Save byronvoorbach/59c9582dcbebcae3c6948413f2d9d6a9 to your computer and use it in GitHub Desktop.
Elasticsearch field collapsing example
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
DELETE shop | |
PUT shop | |
{ | |
"settings": { | |
"number_of_shards": 1, | |
"number_of_replicas": 0 | |
}, | |
"mappings": { | |
"product": { | |
"properties": { | |
"title": { | |
"type": "text" | |
}, | |
"colour": { | |
"type": "keyword" | |
}, | |
"brand": { | |
"type": "text" | |
}, | |
"size": { | |
"type": "text" | |
}, | |
"price": { | |
"type": "double" | |
}, | |
"family_id": { | |
"type": "keyword" | |
} | |
} | |
} | |
} | |
} | |
POST shop/product/1 | |
{ | |
"title": "iPad Air 2", | |
"colour": "Silver", | |
"brand": "Apple", | |
"size": "32gb", | |
"price": 399, | |
"family_id": "apple-1234" | |
} | |
POST shop/product/2 | |
{ | |
"title": "iPad Air 2", | |
"colour": "Gold", | |
"brand": "Apple", | |
"size": "32gb", | |
"price": 399, | |
"family_id": "apple-1234" | |
} | |
POST shop/product/3 | |
{ | |
"title": "iPad Air 2", | |
"colour": "Space Grey", | |
"brand": "Apple", | |
"size": "32gb", | |
"price": 399, | |
"family_id": "apple-1234" | |
} | |
POST shop/product/4 | |
{ | |
"title": "iPad Air 2", | |
"colour": "Space Grey", | |
"brand": "Apple", | |
"size": "128gb", | |
"price": 499, | |
"family_id": "apple-1234" | |
} | |
POST shop/product/5 | |
{ | |
"title": "iPad Pro", | |
"colour": "Space Grey", | |
"brand": "Apple", | |
"size": "128gb", | |
"price": 899, | |
"family_id": "apple-5678" | |
} | |
POST shop/product/6 | |
{ | |
"title": "iPad Pro", | |
"colour": "Space Grey", | |
"brand": "Apple", | |
"size": "256gb", | |
"price": 999, | |
"family_id": "apple-5678" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment