Skip to content

Instantly share code, notes, and snippets.

@mattweber
Created February 27, 2014 04:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattweber/96f3515fc4453a5cb0db to your computer and use it in GitHub Desktop.
Save mattweber/96f3515fc4453a5cb0db to your computer and use it in GitHub Desktop.
category/offer parent/child example
# delete old index if exists
curl -XDELETE 'http://localhost:9200/productindex?pretty'
# Create new Index productindex
curl -XPUT 'http://localhost:9200/productindex?pretty' -d '{
"mappings": {
"categorytype": {
"properties": {
"category": {"type": "string", "index": "not_analyzed"}
}
},
"offertype": {
"_parent": {"type": "categorytype"}
}
}
}'
curl -XPUT 'http://localhost:9200/productindex/offertype/1?pretty&parent=1983001' -d '{"skuid": "1983001", "offer_id": "promo00001,promo00002,promo00003"}'
curl -XPUT 'http://localhost:9200/productindex/offertype/2?pretty&parent=1983002' -d '{"skuid": "1983002", "offer_id": "promo00001,promo00002"}'
curl -XPUT 'http://localhost:9200/productindex/offertype/3?pretty&parent=1983003' -d '{"skuid": "1983003", "offer_id": "promo00001,promo00003"}'
curl -XPUT 'http://localhost:9200/productindex/offertype/1?pretty&parent=1983004' -d '{"skuid": "1983004", "offer_id": "promo00001,promo00002,promo00003"}'
curl -XPUT 'http://localhost:9200/productindex/offertype/2?pretty&parent=1983005' -d '{"skuid": "1983005", "offer_id": "promo00001,promo00002"}'
curl -XPUT 'http://localhost:9200/productindex/offertype/3?pretty&parent=1983006' -d '{"skuid": "1983006", "offer_id": "promo00001,promo00003"}'
curl -XPUT 'http://localhost:9200/productindex/categorytype/1983001?pretty' -d '{"skuid": "1983001", "category": "Flat TV"}'
curl -XPUT 'http://localhost:9200/productindex/categorytype/1983002?pretty' -d '{"skuid": "1983002", "category": "Flat TV"}'
curl -XPUT 'http://localhost:9200/productindex/categorytype/1983003?pretty&refresh=true' -d '{"skuid": "1983003", "category": "Flat TV"}'
curl -XPUT 'http://localhost:9200/productindex/categorytype/1983004?pretty' -d '{"skuid": "1983004", "category": "Mobile"}'
curl -XPUT 'http://localhost:9200/productindex/categorytype/1983005?pretty' -d '{"skuid": "1983005", "category": "Mobile"}'
curl -XPUT 'http://localhost:9200/productindex/categorytype/1983006?pretty&refresh=true' -d '{"skuid": "1983006", "category": "Mobile"}'
curl -XPOST 'http://localhost:9200/productindex/_search?pretty' -d '{
"query": {
"constant_score": {
"filter": {
"has_parent": {
"parent_type": "categorytype",
"filter": {
"term": {"category": "Flat TV"}
}
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment