Skip to content

Instantly share code, notes, and snippets.

@luizgpsantos
Created September 12, 2014 13:53

Revisions

  1. luizgpsantos created this gist Sep 12, 2014.
    21 changes: 21 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    from elasticsearch import Elasticsearch

    es = Elasticsearch(hosts=[{"host": "localhost", "port": 9200}])

    print es.search(body={
    "query": {
    "function_score": {
    "query": {
    "match_all": {}
    },
    "functions": [
    {
    "script_score": {
    "script": "if(sleep(30))1 else 2",
    "lang": "groovy"
    }
    }
    ]
    }
    }
    })