title: Facets and Multiple/Stable/Deterministic Sorting in Elasticsearch
body: <p>Do facets support either:</p>
  
  <ol>
  <li>Deterministic/stable sorting if there are equal values</li>
  <li>If not, a way to allow this using multiple sorts. Sort first by A, then if A's are equal, sort by B.</li>
  </ol>
  
  <p>This is my query:</p>
  
  <pre><code>POST /some_index/_search
  {
    "query": {
      "filtered": {
        "query": {
          "match_all": {}
        }
      }
    },
    "facets": {
      "facet_name": {
        "terms_stats": {
          "key_field": "bucket_id",
          "value_field": "price",
          "order": "mean",
          "size": 100
        }
      }
    }
  }
  </code></pre>
  
  <p>If bucket_id 90 , 91 .... 100, 101.. 105 all have the same mean price, then </p>
  
  <ol>
  <li>Would I potentially get a different result set each time because of a non-deterministic sort?</li>
  <li>If so, how do I change this specific query to order first by mean price and then SECOND by bucket_id.</li>
  </ol>