Skip to content

Instantly share code, notes, and snippets.

@damienalexandre
Created September 16, 2013 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damienalexandre/6581850 to your computer and use it in GitHub Desktop.
Save damienalexandre/6581850 to your computer and use it in GitHub Desktop.
curl -XDELETE 'http://localhost:9200/pony_index_tmp'
curl -XPUT 'http://localhost:9200/pony_index_tmp' -d '
{
"number_of_shards": 1,
"number_of_replicas": 0
}'
curl -XPUT 'http://localhost:9200/pony_index_tmp/label/_mapping' -d '
{
"label": {
"properties": {
"id": {
"type": "integer"
},
"zone": {
"type": "nested",
"fields": {
"zones": {
"type": "string"
},
"start_date": {
"type": "date"
}
}
}
}
}
}'
curl -XPOST "http://localhost:9200/pony_index_tmp/label/1" -d '
{
"id":1,
"zone": [
{ "zones": ["FR", "DE"], "start_date": "2012-01-01" },
{ "zones": ["NZ"], "start_date": "2011-01-01" }
]
}
'
curl -XPOST "http://localhost:9200/pony_index_tmp/label/2" -d '
{
"id":2,
"zone": [
{ "zones": ["FR", "DE"], "start_date": "2012-01-01" },
{ "zones": ["NZ"], "start_date": "2011-01-01" }
]
}
'
curl -XPOST "http://localhost:9200/pony_index_tmp/label/3" -d '
{
"id":3,
"zone": [
{ "zones": ["FR", "DE"], "start_date": "2012-01-01" },
{ "zones": ["NZ"], "start_date": "2011-01-01" }
]
}
'
curl -XPOST "http://localhost:9200/pony_index_tmp/label/4" -d '
{
"id":4,
"zone": [
{ "zones": ["FR", "DE"], "start_date": "2012-01-01" },
{ "zones": ["NZ"], "start_date": "2011-01-01" }
]
}
'
curl -XPOST "http://localhost:9200/pony_index_tmp/label/5" -d '
{
"id":5,
"zone": [
{ "zones": ["JP"], "start_date": "2012-01-01" }
]
}
'
curl -XPOST 'http://localhost:9200/pony_index_tmp/_search?pretty=true' -d '
{ "query": { "match_all" : {} } }'
curl -XPOST 'http://localhost:9200/pony_index_tmp/_search?pretty=true' -d '
{
"query": {
"filtered": {
"query": { "match_all": {} },
"filter": {
"nested": {
"path": "zone",
"_cache" : true, "_name": "testing_FR",
"query": {
"bool": {
"must": [
{
"field": {
"zone.zones": {
"query": "FR"
}
}
},
{
"range": {
"zone.start_date": {
"lte": "2013-09-16"
}
}
}
]
}
}
}
}
}
}
}'
curl -XPOST 'http://localhost:9200/pony_index_tmp/_search?pretty=true' -d '
{
"query": {
"filtered": {
"query": { "match_all": {} },
"filter": {
"nested": {
"path": "zone",
"query": {
"bool": {
"must": [
{
"field": {
"zone.zones": {
"query": "FR"
}
}
},
{
"range": {
"zone.start_date": {
"lte": "2013-09-16"
}
}
}
]
}
}
}
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment