title: Elasticsearch painless Query to compare date field value with user input date value
body: <p>ES index field for a date type looks like</p>
  
  <p>"docdate" : {
              "type" : "date",
              "fields" : {
                "text" : {
                  "type" : "text",
                  "analyzer" : "autocomplete"
                }
              }
            }</p>
  
  <p>query should check the docdate value with user input param value passed through query as below.</p>
  
  <pre><code>                "script": {
                      "script": {
                          "source": "def effecDate=doc['docdate'].value; def sf = new SimpleDateFormat('yyyy-MM-dd'); (sf.parse(params.userdate).after(sf.parse(effecDate)) || (sf.parse(params.userdate) == sf.parse(effecDate)) ",
                          "lang": "painless",
                          "params": {
                              "userdate": "2020-12-01"
                          }
                      }
                  }
  </code></pre>
  
  <p>getting below casting error. </p>
  
  <p>class_cast_exception: Cannot cast org.elasticsearch.script.JodaCompatibleZonedDateTime to java.lang.String</p>
  
  <p>how to achive this query. no data type to field should be added</p>