title: how to filter with script in elasticsearch
body: <p>I need to search for something like this</p>
  
  <pre><code>POST dev_profiles/profiles/_search
  {
    "query": {
      "bool": {
        "filter": [
          {
            "query_string": {
              "query": "user:asd"
            },
            "script_fields": {
              "message_age": {
                "script": {
                  "source": "return doc.createdAt.value.getHour() == params.h",
                  "params": {
                    "h": 9
                  }
                }
              }
            }
          }
        ]
      }
    }
  }
  </code></pre>
  
  <p>but can't build a query in the right way. Can somebody help?</p>
  
  <p>In that case, it gives error [query_string] malformed query, expected [END_OBJECT] but found [FIELD_NAME]
  version of elasticsearch 6.8</p>