title: Return first n element from array in elasticsearch query
body: <p>I have an array field in document named as IP which contains above 10000 ips as element.</p>
  <p>for e.g.</p>
  <pre><code>IP:[&quot;192.168.a:A&quot;,&quot;192.168.a:B&quot;,&quot;192.168.a:C&quot;,&quot;192.168.A:b&quot;...........]
  </code></pre>
  <p>Now i made a search query with some filter and i got the results but the problem is size of result very huge because of above field.</p>
  <p>Now I want to fetch only N ips from array let say only 10 order doesn't matters.</p>
  <p>So How do i do that...</p>
  <p>update:</p>
  <p>Apart from IP field there are others fields also and i applied filter on that field not on IP .I want whole document which satisfies filters .I just want to limit the number of elements in single IP fields.(Let me know if there is any other way apart from using script also ).</p>