Skip to content

Instantly share code, notes, and snippets.

@drewr
Created December 9, 2012 20:03
Show Gist options
  • Save drewr/4246756 to your computer and use it in GitHub Desktop.
Save drewr/4246756 to your computer and use it in GitHub Desktop.
#!/bin/sh
alias c="curl -s"
c -XDELETE localhost:9200/bhelx >/dev/null
c -XPUT localhost:9200/bhelx/t/1 -d '
{
"tags": [
"foo",
"bar",
"baz"
]
}
'
echo
c -XPUT localhost:9200/bhelx/t/2 -d '
{
"tags": [
"foo",
"biz",
"quux"
]
}
'
echo
c -XPOST localhost:9200/bhelx/_refresh; echo
c localhost:9200/bhelx/_search -d '
{
"facets": {
"foo": {
"terms": {
"field": "tags",
"regex": "bi.*"
}
}
},
"query": {
"field": {
"tags": "biz"
}
},
"size": 0
}
'
echo
## {"ok":true,"_index":"bhelx","_type":"t","_id":"1","_version":1}
## {"ok":true,"_index":"bhelx","_type":"t","_id":"2","_version":1}
## {"ok":true,"_shards":{"total":10,"successful":5,"failed":0}}
## {
## "_shards": {
## "failed": 0,
## "successful": 5,
## "total": 5
## },
## "facets": {
## "foo": {
## "_type": "terms",
## "missing": 0,
## "other": 2,
## "terms": [
## {
## "count": 1,
## "term": "biz"
## }
## ],
## "total": 3
## }
## },
## "hits": {
## "hits": [],
## "max_score": 0.15342641,
## "total": 1
## },
## "timed_out": false,
## "took": 2
## }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment