Skip to content

Instantly share code, notes, and snippets.

@axeff
Last active August 29, 2015 14:01
Show Gist options
  • Save axeff/bacf3bb2119f7589e612 to your computer and use it in GitHub Desktop.
Save axeff/bacf3bb2119f7589e612 to your computer and use it in GitHub Desktop.
//create index videos, type test with mapping
curl -XPUT localhost:9200/videos/ -d '
{
"mappings" : {
"test" : {
"properties" : {
"playlists": {
"type": "nested",
"properties" : {
"name" : {
"type": "multi_field",
"fields" : {
"name": {"type" : "string", "index" : "analyzed", "store": "yes"},
"untouched" : {"type" : "string", "index" : "not_analyzed"}
}
},
"position" : {
"type" : "string"
}
}
}
}
}
}
}
'
//put one entry
curl -XPUT 'http://localhost:9200/videos/test/1' -d '{
"playlists" : [
{
"name": "de-classics",
"position" : "1"
},
{
"name": "at-classics",
"position" : "2"
}
]
}'
//facet search
{
"query": {
"match_all": {}
},
"facets": {
"playlists": {
"terms": {
"field": "playlists.name",
"size": 1000
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment