Skip to content

Instantly share code, notes, and snippets.

@drewr
Created December 7, 2012 16:46
Show Gist options
  • Save drewr/4234562 to your computer and use it in GitHub Desktop.
Save drewr/4234562 to your computer and use it in GitHub Desktop.
#!/bin/sh
alias c="curl -s"
c -XDELETE localhost:9200/ove_rebel
echo
c -XPUT localhost:9200/ove_rebel -d '
{
"mappings": {
"records": {
"properties": {
"title": {
"analyzer": "keyword",
"type": "string"
}
}
}
}
}
'
echo
c -XPUT 'http://localhost:9200/ove_rebel/records/1' -d '
{
"id":1,
"title": "A",
"text" : "blah"
}'
echo
c -XPUT 'http://localhost:9200/ove_rebel/records/2' -d '
{
"id":2,
"title": "B",
"text" : "blah blah"
}'
echo
c -XPUT 'http://localhost:9200/ove_rebel/records/3' -d '
{
"id":3,
"title": "A",
"text" : "blah blah blah"
}'
echo
c -XPOST localhost:9200/ove_rebel/_refresh
echo
c -XGET 'http://localhost:9200/ove_rebel/_search' -d '
{
"facets": {
"title": {
"terms": {
"field": "title"
}
}
},
"query": {
"match_all": {}
}
}
'
## {"ok":true,"acknowledged":true}
## {"ok":true,"acknowledged":true}
## {"ok":true,"_index":"ove_rebel","_type":"records","_id":"1","_version":1}
## {"ok":true,"_index":"ove_rebel","_type":"records","_id":"2","_version":1}
## {"ok":true,"_index":"ove_rebel","_type":"records","_id":"3","_version":1}
## {"ok":true,"_shards":{"total":10,"successful":9,"failed":0}}
## {
## "_shards": {
## "failed": 0,
## "successful": 5,
## "total": 5
## },
## "facets": {
## "title": {
## "_type": "terms",
## "missing": 0,
## "other": 0,
## "terms": [
## {
## "count": 2,
## "term": "A"
## },
## {
## "count": 1,
## "term": "B"
## }
## ],
## "total": 3
## }
## },
## "hits": {
## "hits": [
## {
## "_id": "1",
## "_index": "ove_rebel",
## "_score": 1.0,
## "_source": {
## "id": 1,
## "text": "blah",
## "title": "A"
## },
## "_type": "records"
## },
## {
## "_id": "2",
## "_index": "ove_rebel",
## "_score": 1.0,
## "_source": {
## "id": 2,
## "text": "blah blah",
## "title": "B"
## },
## "_type": "records"
## },
## {
## "_id": "3",
## "_index": "ove_rebel",
## "_score": 1.0,
## "_source": {
## "id": 3,
## "text": "blah blah blah",
## "title": "A"
## },
## "_type": "records"
## }
## ],
## "max_score": 1.0,
## "total": 3
## },
## "timed_out": false,
## "took": 14
## }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment