title: How to specifiy "precision" when sorting on date fields in Elasticsearch?
body: <p>I have a field of type <code>date</code> (input format <code>epoch_second</code>) in my Elasticsearch mapping (I'm using ES 2.1). I know that I can sort on that field like</p>
  
  <pre><code>{
    "sort": [
      {
         "myDateField" : {
           "order": "desc"
          }
      }
    ]
  }
  </code></pre>
  
  <p>But this sorts in seconds precision. I'd like to sort by "week interval" (7 day intervals backward from now) and within the same week by score again, like this (pseduocode):</p>
  
  <pre><code>{
    "sort": [
      {
         "myDateField" : {
           "order"     : "desc",
           "precision" : "week"
          }
      },
      "_score"
    ]
  }
  </code></pre>
  
  <p>So, all hits being within the last 7 days should be ranked equally, all hits older than 7 days and younger than 14 days in the next "sort group" and so on. And each "week group" should be sorted by score again.</p>
  
  <p>In words: "What are the most relevant (to the current query) documents from the last 7 days (but don't filter out older ones completly)?"</p>
  
  <p>Background: An event search, where obviously more recent events should matter most.</p>
  
  <p>How can I achieve this?</p>