title: how to sort within a functional boost query in elasticsearch
body: <p>I have an index containing details regarding mobiles, case covers etc.</p>
  
  <p>Below is the query used.</p>
  
  <pre><code>{
  "query": {
      "function_score": {
        "query": { "match": {"title" :"Apple iPhone 6s"} },
        "boost": "5", 
        "functions": [
            {
                "filter": { "match": { "main_category": "mobiles"             } },
                "weight": 8
            },
            {
                "filter": { "match": {"main_category": "cases-and-covers"  } },
                "weight": 6
            }
        ],
        "max_boost": 8,
        "score_mode": "max",
        "boost_mode": "multiply",
        "min_score" : 5
      }
  },
  "_source":["title","main_category","selling_price"],
  "size" : 1000
  </code></pre>
  
  <p>}</p>
  
  <p>Is it possible to boost mobiles category like below and sort within the mobiles category by selling price ascending order.</p>
  
  <p>Boost is working fine. How to sort within the specific boost function?</p>
  
  <p>If user searched for <strong>apple iphone 6s</strong>,I want <strong>mobiles</strong> category to be boosted and <strong>lowest price</strong> should comes first and then case and cover category products also in selling price ascending order. </p>
  
  <p>Below are the results needed</p>
  
  <pre><code>{
     "took": 6,
     "timed_out": false,
     "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
     },
     "hits": {
        "total": 104,
        "max_score": 40.645245,
        "hits": [
           {
              "_index": "test",
              "_type": "products",
              "_id": "shop_24",
              "_score": 40.645245,
              "_source": {
                 "selling_price": 72000,
                 "main_category": "mobiles",
                 "title": "Apple iPhone 6s"
              }
           },
           {
              "_index": "test",
              "_type": "products",
              "_id": "shop_20",
              "_score": 40.168346,
              "_source": {
                 "selling_price": 82000,
                 "main_category": "mobiles",
                 "title": "Apple iPhone 6s Plus"
              }
           },
           {
              "_index": "test",
              "_type": "products",
              "_id": "shop_15",
              "_score": 39.365562,
              "_source": {
                 "selling_price": 92000,
                 "main_category": "mobiles",
                 "title": "Apple iPhone 6s Plus"
              }
           },
           {
              "_index": "test",
              "_type": "products",
              "_id": "shop_17",
              "_score": 39.365562,
              "_source": {
                 "selling_price": 2000,
                 "main_category": "cases-and-covers",
                 "title": "Case cover for Apple iPhone 6s"
              }
           },
           {
              "_index": "test",
              "_type": "products",
              "_id": "shop_18",
              "_score": 39.365562,
              "_source": {
                 "selling_price": 2300,
                 "main_category": "cases-and-covers",
                 "title": "Case cover for Apple iPhone 6s Plus"
              }
           }
        ]
     }
  }
  </code></pre>
  
  <p>Please help?.</p>