Skip to content

Instantly share code, notes, and snippets.

@nikravi
Created January 21, 2015 16:17
Show Gist options
  • Save nikravi/81dcef4b9a656c96ecd5 to your computer and use it in GitHub Desktop.
Save nikravi/81dcef4b9a656c96ecd5 to your computer and use it in GitHub Desktop.
ES query snippets
GET videos/episode/_search
{
"size": 20,
"query": {
"query_string": {
"query": "summer"
}
}
}
//query for any text inside a field
//return only part of the json (_source)
GET videos/episode/_search
{
"size": 20,
"query": {
"query_string": {
"query": "*",
"fields": [
"rights.territory.type"]
}
},
"_source": ["restrictions", "rights"]
}
//query for missing fields, like null, or non-existent fields.
GET videos/episode/_search
{
"size": 10,
"query": {
"filtered": {
"filter": {
"missing": {
"field": "rights.ownership"
}
}
}
},
"_source": [ "restrictions", "rights"]
}
//query by id
GET videos/episode/_search
{
"size": 20,
"query": {
"query_string": {
"query": 10620,
"fields": [
"ids.scrid"
]
}
},
"_source": [ "restrictions", "rights"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment