Elastic Scripting caching issue

HI @dadoonet ,

I am sending the _search request on one of the index with body as :

{
  "from": 0,
  "size": 20,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "is_in_stock": 1
          }
        }
      ]
    }
  },
  "aggs": {
    "min_price": {
      "aggs": {
        "min_price": {
          "nested": {
            "path": "store"
          },
          "aggs": {
            "min_price": {
              "min": {
                "script": "(doc.containsKey('store.warehouse_1162652_price') && (doc['store.warehouse_1162652_price'] != null || doc['store.warehouse_1162652_price'] == 0)) ? doc['store.warehouse_1162652_price'] : doc['store.price']"
              }
            }
          }
        }
      }
    }
  }
}

Here store.warehouse_1162652_price varies with every request. Like it is store.warehouse_1162652_price for this request. It can be store.warehouse_1162687_price for another request .So I am trying to use params for the script. Need to understand how can i write that.