title: Geospatial lookup returns wrong results
body: <p>I have a problem with identifying if a point is within a polygon or not.</p>
  <p>For the same latitude and longitude, sometimes I get right results, but sometimes not. I get wrong results if I search for more IDs (so there are more events) or I change the time range (not necessarily bigger).</p>
  <p>The line which causes the issue: | lookup some_lookup_name latitude longitude</p>
  <p>I have reproduced the issue with sample data and simple geospatial lookup. All events with id=1 are inside the geofence, events with id=2 are outside. I am getting incorrect results (different when sorting according to time). I have two sample data sources (data_sample_2 has changed latitude in one of the events for id=2, from 51.501835 to 51.501836).</p>
  <p><a href="https://i.stack.imgur.com/VjbXN.png" rel="nofollow noreferrer">When sorting from earliest to latest, all events are inside</a></p>
  <p><a href="https://i.stack.imgur.com/ul5tt.png" rel="nofollow noreferrer">When sorting from latest to earliest, some events for id=1 are outside (which is incorrect)</a></p>
  <p><a href="https://i.stack.imgur.com/00yQT.png" rel="nofollow noreferrer">Removing event with problematic latitude</a></p>
  <p>Search:</p>
  <pre><code>index=&quot;debug_idx&quot; source=&quot;data_sample_1&quot;
  | eval time_epoch=_time
  | sort 0 _time
  | lookup geo_4 latitude longitude
  | table id latitude longitude _time time_epoch featureId featureCollection
  | noop search_optimization=false
  </code></pre>
  <p>Data_sample_1:</p>
  <pre><code>{&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-11T01:14:34.000Z&quot;,&quot;latitude&quot;:51.501835,&quot;longitude&quot;:6.906453}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;2&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-11T01:14:34.000Z&quot;,&quot;latitude&quot;:51.501835,&quot;longitude&quot;:6.906453}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;2&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:23:23.000Z&quot;,&quot;latitude&quot;:53.500091,&quot;longitude&quot;:9.909387}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:16:58.000Z&quot;,&quot;latitude&quot;:53.49732,&quot;longitude&quot;:9.9082}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:13:30.000Z&quot;,&quot;latitude&quot;:53.501923,&quot;longitude&quot;:9.910017}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:13:15.000Z&quot;,&quot;latitude&quot;:53.501923,&quot;longitude&quot;:9.910017}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  </code></pre>
  <p>Data_sample_2:</p>
  <pre><code>{&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-11T01:14:34.000Z&quot;,&quot;latitude&quot;:51.501836,&quot;longitude&quot;:6.906453}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;2&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-11T01:14:34.000Z&quot;,&quot;latitude&quot;:51.501835,&quot;longitude&quot;:6.906453}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;2&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:23:23.000Z&quot;,&quot;latitude&quot;:53.500091,&quot;longitude&quot;:9.909387}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:16:58.000Z&quot;,&quot;latitude&quot;:53.49732,&quot;longitude&quot;:9.9082}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:13:30.000Z&quot;,&quot;latitude&quot;:53.501923,&quot;longitude&quot;:9.910017}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  {&quot;location&quot;:{&quot;state&quot;:{&quot;position&quot;:{&quot;timestamp&quot;:&quot;2021-01-06T22:13:15.000Z&quot;,&quot;latitude&quot;:53.501923,&quot;longitude&quot;:9.910017}}},&quot;ident&quot;:{&quot;attr&quot;:{&quot;id&quot;:&quot;1&quot;}}}}
  </code></pre>
  <p>Geolookup_4.kml:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
  &lt;kml xmlns=&quot;http://www.opengis.net/kml/2.2&quot;&gt;
  &lt;Document id=&quot;root_doc&quot;&gt;
  &lt;Schema name=&quot;geo_4&quot; id=&quot;geo_4&quot;&gt;
      &lt;SimpleField name=&quot;Name&quot; type=&quot;string&quot;&gt;&lt;/SimpleField&gt;
  &lt;/Schema&gt;
  &lt;Folder&gt;
  &lt;name&gt;geo_4&lt;/name&gt;
  &lt;Placemark&gt;
      &lt;name&gt;{&quot;place&quot;:&quot;Location 1&quot;,&quot;category&quot;:&quot;Locations&quot;,&quot;description&quot;:[&quot;A&quot;],&quot;subdescription&quot;:&quot;01&quot;}&lt;/name&gt;
      &lt;Style&gt;&lt;LineStyle&gt;&lt;color&gt;ff0000ff&lt;/color&gt;&lt;/LineStyle&gt;&lt;PolyStyle&gt;&lt;fill&gt;0&lt;/fill&gt;&lt;/PolyStyle&gt;&lt;/Style&gt;
      &lt;Polygon&gt;&lt;outerBoundaryIs&gt;&lt;LinearRing&gt;&lt;coordinates&gt;9.92195,53.51249 9.92848,53.49588 9.89352,53.49482 9.89561,53.51567 9.92195,53.51249&lt;/coordinates&gt;&lt;/LinearRing&gt;&lt;/outerBoundaryIs&gt;&lt;/Polygon&gt;
  &lt;/Placemark&gt;
  &lt;/Folder&gt;
  &lt;/Document&gt;&lt;/kml&gt;
  </code></pre>