Skip to content

Instantly share code, notes, and snippets.

@imotov
Created March 27, 2013 00:34
Show Gist options
  • Select an option

  • Save imotov/5250599 to your computer and use it in GitHub Desktop.

Select an option

Save imotov/5250599 to your computer and use it in GitHub Desktop.

Revisions

  1. imotov created this gist Mar 27, 2013.
    78 changes: 78 additions & 0 deletions prices.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    curl -XDELETE "localhost:9200/test"
    curl -XPUT "localhost:9200/test" -d '{
    "mappings": {
    "doc": {
    "properties": {
    "price": {
    "type": "long"
    },
    "colour": {
    "type": "string",
    "index": "not_analyzed"
    },
    "feature": {
    "type": "string",
    "index": "not_analyzed"
    }
    }
    }
    }
    }'
    curl -XPUT "localhost:9200/test/doc/1" -d '{"price": 10, "colour" : "Red", "feature" : ["Square", "Shiny", "Solid"]}'
    curl -XPUT "localhost:9200/test/doc/2" -d '{"price": 30, "colour" : "Red", "feature" : ["Square", "Shiny", "Squishy"]}'
    curl -XPOST "localhost:9200/test/_refresh"
    echo
    curl "localhost:9200/test/doc/_search?pretty=true" -d '{
    query : {
    "filtered" : {
    "query" : {
    "match_all" : {}
    },
    "filter" : {
    "and" : [
    {
    "term" : {
    "colour" : "Red"
    }
    },
    {
    "term" : {
    "feature" : "Square"
    }
    },
    {
    "term" : {
    "feature" : "Shiny"
    }
    }
    ]
    }
    }
    },
    "facets" : {
    "colours" : {
    "terms" : {
    "field" : "colour"
    },
    "facet_filter" : {
    "range" : { "price" : { "from" : "10", "to" : "20" } }
    }
    },
    "features" : {
    "terms" : {
    "field" : "feature"
    },
    "facet_filter" : {
    "range" : { "price" : { "from" : "10", "to" : "20" } }
    }
    },
    "prices" : {
    "statistical" : {
    "field" : "price"
    }
    }
    },
    "filter": {
    "range" : { "price" : { "from" : "10", "to" : "20" } }
    }
    }'