Skip to content

Instantly share code, notes, and snippets.

@nikravi
Created January 21, 2015 16:17
Show Gist options
  • Select an option

  • Save nikravi/81dcef4b9a656c96ecd5 to your computer and use it in GitHub Desktop.

Select an option

Save nikravi/81dcef4b9a656c96ecd5 to your computer and use it in GitHub Desktop.

Revisions

  1. nikravi created this gist Jan 21, 2015.
    59 changes: 59 additions & 0 deletions ES queries
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,59 @@
    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"]
    }