title: How can I get a decay function to work withn the query for elastic search?
body: <p>I am using elastic search to build a simple search engine.</p>
  
  <p>One piece I am trying to nail down is that I want to be able to have more recently released documents get pushed closer to the top of the search results and so I am using an "exp" decay function (gaussian).  I clearly am missing something because it is not working as I expected it to.  I have fiddled with the number to no avail.</p>
  
  <p>The goal is to take this one query (with nothing but the formula in it) and make it return with our more recent documents near the top of the results.  Literally, there are no other pieces to this query.  I have included the "explain" portion of the top result for information.</p>
  
  <p>Please help!  I don't get it....</p>
  
  <pre><code>{        
    "query": {
      "function_score": {
        "exp": {
          "createdAt": {
              "origin": "now",
              "scale": "30d",
              "decay": 0.8,
              "offset": "7d"
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>The first result has this value
  "createdAt": "2007-12-07T11:54:04.000Z",</p>
  
  <p>We have documents that are from 2017 - the top few articles are from 2007!
  I don't understand what is wrong...</p>
  
  <pre><code> "_explanation": {
            "value": 1,
            "description": "function score, product of:",
            "details": [
              {
                "value": 1,
                "description": "*:*, product of:",
                "details": [
                  {
                    "value": 1,
                    "description": "boost",
                    "details": []
                  },
                  {
                    "value": 1,
                    "description": "queryNorm",
                    "details": []
                  }
                ]
              },
              {
                "value": 1,
                "description": "min of:",
                "details": [
                  {
                    "value": 1,
                    "description": "Function for field createdAt:",
                    "details": [
                      {
                        "value": 1,
                        "description": "exp(- MIN[0.0] * 8.608933306875375E-11)",
                        "details": []
                      }
                    ]
                  },
                  {
                    "value": 3.4028235e+38,
                    "description": "maxBoost",
                    "details": []
                  }
                ]
              }
            ]
          }
        },
  </code></pre>