Skip to content

Instantly share code, notes, and snippets.

@pramsey
Created October 13, 2015 23:07
Show Gist options
  • Save pramsey/a0b60811ce0ae2f5124f to your computer and use it in GitHub Desktop.
Save pramsey/a0b60811ce0ae2f5124f to your computer and use it in GitHub Desktop.
Elasticsearch Tests
{"create":{"_index":"taxi","_type":"pickup"}}
{"pickup_datetime":"2010-01-31 23:47:21","passenger_count":1,"trip_time_in_secs":20.33,"trip_distance":6.7,"pickup_location":"dr5ruddw35ry3"}
{"create":{"_index":"taxi","_type":"pickup"}}
{"pickup_datetime":"2010-01-31 23:47:22","passenger_count":1,"trip_time_in_secs":3.63,"trip_distance":1.2,"pickup_location":"dr5revvq6sjee"}
{"create":{"_index":"taxi","_type":"pickup"}}
{"pickup_datetime":"2010-01-31 23:47:22","passenger_count":1,"trip_time_in_secs":15.5,"trip_distance":4,"pickup_location":"dr5rshw6zmcdb"}
{"create":{"_index":"taxi","_type":"pickup"}}
{"pickup_datetime":"2010-01-31 23:47:22","passenger_count":2,"trip_time_in_secs":28.87,"trip_distance":20.5,"pickup_location":"dr5x0yywkqyps"}
{"create":{"_index":"taxi","_type":"pickup"}}
{"pickup_datetime":"2010-01-31 23:47:23","passenger_count":3,"trip_time_in_secs":15.84,"trip_distance":6.4,"pickup_location":"dr5ru3bh473z0"}
{
"pickup" : {
"_all" : { "enabled" : true },
"properties" : {
"pickup_datetime" : {
"type" : "date",
"format" : "YYYY-MM-dd HH:mm:ss"
},
"passenger_count" : { "type" : "integer" },
"trip_time_in_secs" : { "type" : "double" },
"trip_distance" : { "type" : "double" },
"pickup_location" : {
"type" : "geo_point",
"lat_lon" : true,
"geohash" : true,
"geohash_precision" : 12,
"geohash_prefix" : true ,
"fielddata" : {
"format" : "compressed",
"precision" : "1cm"
}
}
}
}
}
###############################################################################
# 15M records
###############################################################################
# how many trips indexed?
# hot 0m0.071s
# {"count":14984572,"_shards":{"total":5,"successful":5,"failed":0}}
#
time curl -XGET 'http://localhost:9200/taxi/pickup/_count'
# how many trips w/ 5 passengers?
# hot 0m0.045s
# {"count":1224791,"_shards":{"total":5,"successful":5,"failed":0}}
#
time curl -XGET 'http://localhost:9200/taxi/pickup/_count' -d '
{
"query" : {
"term" : { "passenger_count" : "5" }
}
}'
#
# summarize full table by # of passengers
# hot 0m0.155s (0.5s cold)
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"size": 0,
"aggs": {
"group_by_passengers": {
"terms": {
"field": "passenger_count"
}
}
}
}'
#
# zoomed out document count per geohash grid cell
# 9008 docs returned, in ~900 points
# hot 0m0.139s
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"myLarge-GrainGeoHashGrid" : {
"filter" : {
"range": {
"trip_time_in_secs": {
"gte": 60,
"lte": 70
}
}
},
"aggregations":{
"zoom1":{
"geohash_grid" : {
"field" : "pickup_location",
"precision" : 6
}
}
}
}
}
}'
#
# histogram of all values in index on the trip_time_in_secs
# 9008 docs returned, in ~900 points
# hot 0m0.286s cold 0.684s
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"trip_time_in_secs" : {
"histogram" : {
"field": "trip_time_in_secs",
"interval": 5
}
}
}
}'
#
# zoomed in document count per geohash grid cell
# returns 133 docs
# hot 0m0.232 (cold 0.335s)
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"zoomedInView" : {
"filter" : {
"geo_bounding_box" : {
"pickup_location" : {
"top_left" : "40.7280960, -73.9850510",
"bottom_right" : "40.7280460, -73.9850010"
}
}
},
"aggregations":{
"zoom1":{
"geohash_grid" : {
"field":"pickup_location",
"precision":10
}
}
}
}
}
}'
#
# histogram of all values in index on the trip_time_in_secs
# within a specific georectangle
# 257 docs returned, in ~900 points
# hot 0m0.234s
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"zoomedInView" : {
"filter" : {
"geo_bounding_box" : {
"pickup_location" : {
"top_left" : "40.7280960, -73.9850510",
"bottom_right" : "40.7280460, -73.9850010"
}
}
},
"aggregations" : {
"trip_time_in_secs" : {
"histogram" : {
"field": "trip_time_in_secs",
"interval": 1
}
}
}
}
}
}'
###############################################################################
# 30M records
###############################################################################
# how many trips indexed?
# hot 0m0.153
# {"count":29846028,"_shards":{"total":5,"successful":5,"failed":0}}
#
time curl -XGET 'http://localhost:9200/taxi/pickup/_count'
# how many trips w/ 5 passengers?
# hot 0m0.035s
# {"count":2583064,"_shards":{"total":5,"successful":5,"failed":0}}
#
time curl -XGET 'http://localhost:9200/taxi/pickup/_count' -d '
{
"query" : {
"term" : { "passenger_count" : "5" }
}
}'
#
# summarize full table by # of passengers
# hot 0m0.302s (0.6s cold)
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"size": 0,
"aggs": {
"group_by_passengers": {
"terms": {
"field": "passenger_count"
}
}
}
}'
#
# zoomed out document count per geohash grid cell
# 17988 docs returned, in ~900 points
# hot 0m0.261
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"myLarge-GrainGeoHashGrid" : {
"filter" : {
"range": {
"trip_time_in_secs": {
"gte": 60,
"lte": 70
}
}
},
"aggregations":{
"zoom1":{
"geohash_grid" : {
"field" : "pickup_location",
"precision" : 6
}
}
}
}
}
}'
#
# histogram of all values in index on the trip_time_in_secs
# hot 0m0.500
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"trip_time_in_secs" : {
"histogram" : {
"field": "trip_time_in_secs",
"interval": 5
}
}
}
}'
#
# zoomed in document count per geohash grid cell
# returns 257 docs
# hot 0m0.420
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"zoomedInView" : {
"filter" : {
"geo_bounding_box" : {
"pickup_location" : {
"top_left" : "40.7280960, -73.9850510",
"bottom_right" : "40.7280460, -73.9850010"
}
}
},
"aggregations":{
"zoom1":{
"geohash_grid" : {
"field":"pickup_location",
"precision":10
}
}
}
}
}
}'
#
# histogram of all values in index on the trip_time_in_secs
# within a specific georectangle
# 257 docs returned, in ~900 points
# hot 0m0.400
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"zoomedInView" : {
"filter" : {
"geo_bounding_box" : {
"pickup_location" : {
"top_left" : "40.7280960, -73.9850510",
"bottom_right" : "40.7280460, -73.9850010"
}
}
},
"aggregations" : {
"trip_time_in_secs" : {
"histogram" : {
"field": "trip_time_in_secs",
"interval": 1
}
}
}
}
}
}'
###############################################################################
# 45M records
###############################################################################
# how many trips indexed?
# hot 0m0.144
# {"count":44707484,"_shards":{"total":5,"successful":5,"failed":0}}
#
time curl -XGET 'http://localhost:9200/taxi/pickup/_count'
# how many trips w/ 5 passengers?
# hot 0m0.055s
# {"count":3869433,"_shards":{"total":5,"successful":5,"failed":0}}
#
time curl -XGET 'http://localhost:9200/taxi/pickup/_count' -d '
{
"query" : {
"term" : { "passenger_count" : "5" }
}
}'
#
# summarize full table by # of passengers
# hot 0m0.547s (1.3s cold)
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"size": 0,
"aggs": {
"group_by_passengers": {
"terms": {
"field": "passenger_count"
}
}
}
}'
#
# zoomed out document count per geohash grid cell
# 17988 docs returned, in ~900 points
# hot 0m0.348 (17s cold)
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"myLarge-GrainGeoHashGrid" : {
"filter" : {
"range": {
"trip_time_in_secs": {
"gte": 60,
"lte": 70
}
}
},
"aggregations":{
"zoom1":{
"geohash_grid" : {
"field" : "pickup_location",
"precision" : 6
}
}
}
}
}
}'
#
# histogram of all values in index on the trip_time_in_secs
# hot 0m0.800 (2s cold)
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"trip_time_in_secs" : {
"histogram" : {
"field": "trip_time_in_secs",
"interval": 5
}
}
}
}'
#
# zoomed in document count per geohash grid cell
# hot 0m0.600
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"zoomedInView" : {
"filter" : {
"geo_bounding_box" : {
"pickup_location" : {
"top_left" : "40.7280960, -73.9850510",
"bottom_right" : "40.7280460, -73.9850010"
}
}
},
"aggregations":{
"zoom1":{
"geohash_grid" : {
"field":"pickup_location",
"precision":10
}
}
}
}
}
}'
#
# histogram of all values in index on the trip_time_in_secs
# within a specific georectangle
# 257 docs returned, in ~900 points
# hot 0m0.656
#
time curl -XPOST 'localhost:9200/taxi/_search?pretty' -d '
{
"aggregations" : {
"zoomedInView" : {
"filter" : {
"geo_bounding_box" : {
"pickup_location" : {
"top_left" : "40.7280960, -73.9850510",
"bottom_right" : "40.7280460, -73.9850010"
}
}
},
"aggregations" : {
"trip_time_in_secs" : {
"histogram" : {
"field": "trip_time_in_secs",
"interval": 1
}
}
}
}
}
}'
curl -XDELETE 'localhost:9200/taxi?pretty'
curl -XPUT 'localhost:9200/taxi?pretty'
curl -XPUT 'localhost:9200/taxi/_mapping/pickup?pretty' --data-binary "@pickup.mapping.json"
curl -XPOST 'localhost:9200/taxi/_bulk?pretty' --data-binary "@pickup.json"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment