Skip to content

Instantly share code, notes, and snippets.

@strukturedkaos
Created June 4, 2015 12:42
Show Gist options
  • Save strukturedkaos/a6151805daabe88b7454 to your computer and use it in GitHub Desktop.
Save strukturedkaos/a6151805daabe88b7454 to your computer and use it in GitHub Desktop.
Elasticsearch exploration
Setup snapshot repo:
curl -XPUT 'http://localhost:9200/_snapshot/demo_nyc_accidents' -d '{
"type": "url",
"settings": {
"url": "http://download.elasticsearch.org/demos/nycopendata/snapshot/"
}
}'
# Monitor recovery:
curl -XPOST 'http://localhost:9200/_snapshot/demo_nyc_accidents/demo_nyc_accidents/_restore'
CURL -XGET 'http://localhost:9200/nyc_visionzero/_search?search_type=count' -d '{
"aggs" : {
"all_boroughs": {
"terms": {
"field": "borough"
}
}
}
}' | pp
CURL -XGET 'http://localhost:9200/nyc_visionzero/_search?search_type=count' -d '{
"aggs" : {
"months": {
"date_histogram": {
"field": "@timestamp",
"interval": "month"
}
}
}
}' | pp
response = Product.search query: { match: { title: "Fox Dogs" } },
highlight: { fields: { title: {} } }
response.results.first.highlight.title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment