Skip to content

Instantly share code, notes, and snippets.

@wflanagan
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wflanagan/eb44812a9272c0528b73 to your computer and use it in GitHub Desktop.
Save wflanagan/eb44812a9272c0528b73 to your computer and use it in GitHub Desktop.
{:created_at=>{:type=>"date"},
:updated_at=>{:type=>"date"},
:domain_id=>{:type=>"integer"},
:users=>{:type=>"integer"},
:new_users=>{:type=>"integer"},
:sessions=>{:type=>"integer"},
:pageviews=>{:type=>"integer"},
:session_duration=>{:type=>"integer"},
:bounces=>{:type=>"integer"},
:exits=>{:type=>"integer"},
:conversion_rate=>{:type=>"integer"},
:goals=>{:type=>"integer"},
:assists=>{:type=>"integer"},
:unique_referrers=>{:type=>"integer"},
:mediums=>{:type=>"string", :index=>:not_analyzed},
:sources=>{:type=>"string", :index=>:not_analyzed},
:goal_ids=>{:type=>"string"},
:by_goal=>
{:type=>"nested",
:properties=>
{:id=>{:type=>"integer"},
:count=>{:type=>"integer"},
:by_source=>{:type=>"nested", :properties=>{:id=>{:type=>"string", :index=>:not_analyzed}, :count=>{:type=>"integer"}}},
:by_medium=>{:type=>"nested", :properties=>{:id=>{:type=>"string", :index=>:not_analyzed}, :count=>{:type=>"integer"}}},
:by_referral=>
{:type=>"nested", :properties=>{:id=>{:type=>"string", :index=>:not_analyzed}, :count=>{:type=>"integer"}}}}},
:by_medium=>
{:type=>"nested",
:properties=>
{:id=>{:type=>"string", :index=>:not_analyzed},
:count=>{:type=>"integer"},
:by_goal=>{:type=>"nested", :properties=>{:id=>{:type=>"integer"}, :count=>{:type=>"integer"}}},
:by_source=>
{:type=>"nested", :properties=>{:id=>{:type=>"string", :index=>:not_analyzed}, :count=>{:type=>"integer"}}}}},
:by_source=>
{:type=>"nested",
:properties=>
{:id=>{:type=>"string", :index=>:not_analyzed},
:count=>{:type=>"integer"},
:by_goal=>{:type=>"nested", :properties=>{:id=>{:type=>"integer"}, :count=>{:type=>"integer"}}},
:by_medium=>
{:type=>"nested", :properties=>{:id=>{:type=>"string", :index=>:not_analyzed}, :count=>{:type=>"integer"}}}}},
:by_assist=>{:type=>"nested", :properties=>{:id=>{:type=>"integer"}, :count=>{:type=>"integer"}}},
:url=>{:type=>"string", :index=>:not_analyzed},
:timestamp=>{:type=>"date"},
:rdn_url=>{:type=>"string", :index=>:not_analyzed},
:scheme=>{:type=>"string", :index=>:not_analyzed},
:host=>{:type=>"string", :index=>:not_analyzed},
:port=>{:type=>"integer"},
:path=>{:type=>"string", :index=>:not_analyzed},
:query_string=>{:type=>"string", :index=>:not_analyzed},
:actions=>{:type=>"integer"},
:crawl_page_id=>{:type=>"string", :index=>:not_analyzed}}
{
'by_day' => {
'date_histogram' => {'field' => 'timestamp', 'interval' => '1d', 'min_doc_count' => 0 },
'aggs' => {
'sessions' => {
"sum" => { "field" => "sessions" }
},
'goals' => {
'sum' => {'field' => 'goals'}
},
'assists' => {
'sum' => { 'field' => 'assists'}
},
'users' => {
'sum' => { 'field' => 'users'}
},
'by_goals' => {
'nested' => {'path' => 'by_goal'},
'aggs' => {
'source' => {
"terms" => { "field" => "by_goal.id", 'size' => 100 },
'aggs' => {
'by_source' => {
'nested' => {'path' => 'by_goal'},
'aggs' => {
'sources' => {
'terms' => {'field' => 'by_goal.by_source.id'}
}
}
}
}
}
}
}
}
}
}
[{"key_as_string"=>"2015-07-04T00:00:00.000Z",
"key"=>1435968000000,
"doc_count"=>3,
"by_goals"=>
{"doc_count"=>1,
"source"=>{"buckets"=>[{"key"=>4, "doc_count"=>1, "by_source"=>{"doc_count"=>0, "sources"=>{"buckets"=>[]}}}]}},
"goals"=>{"value"=>2.0},
"users"=>{"value"=>11.0},
"assists"=>{"value"=>4.0},
"sessions"=>{"value"=>10.0}},
{"key_as_string"=>"2015-07-05T00:00:00.000Z",
"key"=>1436054400000,
"doc_count"=>8,
"by_goals"=>
{"doc_count"=>2,
"source"=>
{"buckets"=>
[{"key"=>1, "doc_count"=>1, "by_source"=>{"doc_count"=>0, "sources"=>{"buckets"=>[]}}},
{"key"=>2, "doc_count"=>1, "by_source"=>{"doc_count"=>0, "sources"=>{"buckets"=>[]}}}]}},
"goals"=>{"value"=>4.0},
"users"=>{"value"=>7.0},
"assists"=>{"value"=>8.0},
"sessions"=>{"value"=>2.0}},
{"key_as_string"=>"2015-07-06T00:00:00.000Z",
"key"=>1436140800000,
"doc_count"=>7,
"by_goals"=>
{"doc_count"=>2,
"source"=>
{"buckets"=>
[{"key"=>1, "doc_count"=>1, "by_source"=>{"doc_count"=>0, "sources"=>{"buckets"=>[]}}},
{"key"=>4, "doc_count"=>1, "by_source"=>{"doc_count"=>0, "sources"=>{"buckets"=>[]}}}]}},
"goals"=>{"value"=>4.0},
"users"=>{"value"=>97.0},
"assists"=>{"value"=>8.0},
"sessions"=>{"value"=>89.0}}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment