title: Elasticsearch compare two fields
body: <p>For example MySQL query</p>
  
  <pre><code>SELECT fields_a, fields_b FROM table WHERE fields_a &gt; fields_b;
  </code></pre>
  
  <p>I am trying to implement for elasticsearch. I've tried, as follows: </p>
  
  <pre><code>$where = [ "query" =&gt; [ "filter" =&gt; [ "script" =&gt; [ "script" =&gt; "doc[\"fields_a\"].value &gt; doc[\"fields_b\"].value" ] ] ] ];
  </code></pre>
  
  <p>What am I missing?</p>