title: Check if id exist in array field or not using script_fields
body: <p>i like to get a script field if a specific value exist in a array .</p>
  <p>Here is my mapping -</p>
  <pre><code>&quot;mappings&quot;: {
      &quot;properties&quot;: {
          &quot;field1&quot;: {
              &quot;type&quot;: &quot;text&quot;,
          },
          &quot;field2&quot;: {
              &quot;type&quot;: &quot;text&quot;,
          },
      }
  }
  </code></pre>
  <p>Here is my example documents -</p>
  <pre><code>{
      &quot;field1&quot;: &quot;hello 1&quot;,
      &quot;field2&quot;: [&quot;id1&quot;,&quot;id3&quot;]
  }
  
  {
      &quot;field1&quot;: &quot;hello 2&quot;,
      &quot;field2&quot;: [&quot;id2&quot;,&quot;id3&quot;]
  }
  {
      &quot;field1&quot;: &quot;hello 3&quot;,
  
  }
  {
      &quot;field1&quot;: &quot;mobile 1&quot;,
      &quot;field2&quot;: [&quot;id1&quot;,&quot;id4&quot;]
  }
  </code></pre>
  <p>Here is my search query -</p>
  <pre><code>{
      &quot;query&quot;: {
          &quot;match&quot; : {
              &quot;title&quot;: &quot;hello&quot;
          }
      },
      &quot;script_fields&quot;:{
          &quot;testField2&quot;:{
              &quot;script&quot;: {
                  &quot;source&quot;:&quot;doc['field2'].value ==  params.id ? true : false&quot;,
                  &quot;params&quot;: {
                      &quot;id&quot;: &quot;id1&quot;
                  }
              }
          }
      }
  
  }
  </code></pre>
  <p>what i want to achieve is to get all those document which has &quot;hello&quot; in their title and add a custom field (testField2) in every doc . the value of that custom field would be True if &quot;field2&quot; contain a specific id (&quot;id1&quot;) else False</p>