Let's say that I'm using Elasticsearch to host and query log data, and I 
want to do some basic analysis of it like I would in Google Analytics. One 
of the most basic differentiations I'm having trouble with is pageviews vs. 
unique pageviews. I'm sure there's a very simple solution, but for some 
reason it's escaping me.

Here's a sample mapping:

 {
  "log-data": {
    "properties": {
      "date": {
        "type": "date",
        "format": "dateOptionalTime"
      },
      "uid": {
        "type": "string"
      },
      "url": {
        "type": "string"
      }
    }
  }
 }


"date" and "url" are pretty obvious; "uid" is a unique identifier.

If I want to get the total pageviews for the top 10 URLs for the past week, 
I can query it like so:

 {
  "query": {
    "range": {
      "date": {
        "gte" : "now-1w"
      }
    }
  },
  "facets": {
    "pageview": {
      "terms": {
        "field": "url",
        "size": 10
      }
    }
  },
  "size": 0
 }


What I'm struggling with is bringing the "uid" into the query to get unique 
pageviews. Any help would be greatly appreciated!

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/215897fd-4639-4b90-8308-80318fd2a283%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to