**Build scan:**
https://gradle-enterprise.elastic.co/s/p7n7etkicebme/tests/:x-pack:plugin:spatial:internalClusterTest/org.elasticsearch.xpack.spatial.search.CartesianShapeQueryTests/testQueryRandomGeoCollection

**Reproduction line:**
`./gradlew ':x-pack:plugin:spatial:internalClusterTest' --tests "org.elasticsearch.xpack.spatial.search.CartesianShapeQueryTests.testQueryRandomGeoCollection" -Dtests.seed=D42035A03986D727 -Dtests.locale=lt -Dtests.timezone=Asia/Baku -Druntime.java=17`

**Applicable branches:**
master

**Reproduces locally?:**
No

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.spatial.search.CartesianShapeQueryTests&tests.test=testQueryRandomGeoCollection

**Failure excerpt:**
```
org.elasticsearch.index.mapper.MapperParsingException: failed to parse field [geo] of type [shape]

  at __randomizedtesting.SeedInfo.seed([D42035A03986D727:CCF71E7B64748804]:0)
  at org.elasticsearch.index.mapper.AbstractGeometryFieldMapper.lambda$parse$1(AbstractGeometryFieldMapper.java:191)
  at org.elasticsearch.xpack.spatial.index.mapper.ShapeParser.parse(ShapeParser.java:40)
  at org.elasticsearch.index.mapper.AbstractGeometryFieldMapper.parse(AbstractGeometryFieldMapper.java:187)
  at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:409)
  at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:461)
  at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:313)
  at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:278)
  at org.elasticsearch.index.mapper.DocumentParser.internalParseDocument(DocumentParser.java:127)
  at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:79)
  at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:78)
  at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:999)
  at org.elasticsearch.index.shard.IndexShard.applyIndexOperation(IndexShard.java:948)
  at org.elasticsearch.index.shard.IndexShard.applyIndexOperationOnPrimary(IndexShard.java:892)
  at org.elasticsearch.action.bulk.TransportShardBulkAction.executeBulkItemRequest(TransportShardBulkAction.java:321)
  at org.elasticsearch.action.bulk.TransportShardBulkAction$2.doRun(TransportShardBulkAction.java:187)
  at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
  at org.elasticsearch.action.bulk.TransportShardBulkAction.performOnPrimary(TransportShardBulkAction.java:253)
  at org.elasticsearch.action.bulk.TransportShardBulkAction.dispatchedShardOperationOnPrimary(TransportShardBulkAction.java:133)
  at org.elasticsearch.action.bulk.TransportShardBulkAction.dispatchedShardOperationOnPrimary(TransportShardBulkAction.java:72)
  at org.elasticsearch.action.support.replication.TransportWriteAction$1.doRun(TransportWriteAction.java:211)
  at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:769)
  at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  at java.lang.Thread.run(Thread.java:833)

  Caused by: java.lang.IllegalArgumentException: at least three non-collinear points required

    at org.apache.lucene.geo.Tessellator.tessellate(Tessellator.java:174)
    at org.apache.lucene.geo.Tessellator.tessellate(Tessellator.java:152)
    at org.apache.lucene.document.XYShape.createIndexableFields(XYShape.java:83)
    at org.apache.lucene.document.XYShape.createIndexableFields(XYShape.java:72)
    at org.elasticsearch.xpack.spatial.index.mapper.CartesianShapeIndexer$LuceneGeometryVisitor.visit(CartesianShapeIndexer.java:114)
    at org.elasticsearch.xpack.spatial.index.mapper.CartesianShapeIndexer$LuceneGeometryVisitor.visit(CartesianShapeIndexer.java:50)
    at org.elasticsearch.geometry.Polygon.visit(Polygon.java:84)
    at org.elasticsearch.xpack.spatial.index.mapper.CartesianShapeIndexer$LuceneGeometryVisitor.visit(CartesianShapeIndexer.java:66)
    at org.elasticsearch.xpack.spatial.index.mapper.CartesianShapeIndexer$LuceneGeometryVisitor.visit(CartesianShapeIndexer.java:50)
    at org.elasticsearch.geometry.GeometryCollection.visit(GeometryCollection.java:51)
    at org.elasticsearch.xpack.spatial.index.mapper.CartesianShapeIndexer.indexShape(CartesianShapeIndexer.java:46)
    at org.elasticsearch.xpack.spatial.index.mapper.ShapeFieldMapper.index(ShapeFieldMapper.java:187)
    at org.elasticsearch.xpack.spatial.index.mapper.ShapeFieldMapper.index(ShapeFieldMapper.java:52)
    at org.elasticsearch.index.mapper.AbstractGeometryFieldMapper.lambda$parse$0(AbstractGeometryFieldMapper.java:187)
    at org.elasticsearch.xpack.spatial.index.mapper.ShapeParser.parse(ShapeParser.java:37)
    at org.elasticsearch.index.mapper.AbstractGeometryFieldMapper.parse(AbstractGeometryFieldMapper.java:187)
    at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrField(DocumentParser.java:409)
    at org.elasticsearch.index.mapper.DocumentParser.parseObject(DocumentParser.java:461)
    at org.elasticsearch.index.mapper.DocumentParser.innerParseObject(DocumentParser.java:313)
    at org.elasticsearch.index.mapper.DocumentParser.parseObjectOrNested(DocumentParser.java:278)
    at org.elasticsearch.index.mapper.DocumentParser.internalParseDocument(DocumentParser.java:127)
    at org.elasticsearch.index.mapper.DocumentParser.parseDocument(DocumentParser.java:79)
    at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:78)
    at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:999)
    at org.elasticsearch.index.shard.IndexShard.applyIndexOperation(IndexShard.java:948)
    at org.elasticsearch.index.shard.IndexShard.applyIndexOperationOnPrimary(IndexShard.java:892)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.executeBulkItemRequest(TransportShardBulkAction.java:321)
    at org.elasticsearch.action.bulk.TransportShardBulkAction$2.doRun(TransportShardBulkAction.java:187)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.performOnPrimary(TransportShardBulkAction.java:253)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.dispatchedShardOperationOnPrimary(TransportShardBulkAction.java:133)
    at org.elasticsearch.action.bulk.TransportShardBulkAction.dispatchedShardOperationOnPrimary(TransportShardBulkAction.java:72)
    at org.elasticsearch.action.support.replication.TransportWriteAction$1.doRun(TransportWriteAction.java:211)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:769)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.lang.Thread.run(Thread.java:833)

```
x-pack/plugin/spatial/src/test/java/org/elasticsearch/xpack/spatial/util/ShapeTestUtils.java
/*
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License
 * 2.0; you may not use this file except in compliance with the Elastic License
 * 2.0.
 */
package org.elasticsearch.xpack.spatial.util;
import org.apache.lucene.geo.XShapeTestUtil;
import org.apache.lucene.geo.XYCircle;
import org.apache.lucene.geo.XYPolygon;
import org.elasticsearch.geometry.Circle;
import org.elasticsearch.geometry.Geometry;
import org.elasticsearch.geometry.GeometryCollection;
import org.elasticsearch.geometry.Line;
import org.elasticsearch.geometry.LinearRing;
import org.elasticsearch.geometry.MultiLine;
import org.elasticsearch.geometry.MultiPoint;
import org.elasticsearch.geometry.MultiPolygon;
import org.elasticsearch.geometry.Point;
import org.elasticsearch.geometry.Polygon;
import org.elasticsearch.geometry.Rectangle;
import org.elasticsearch.test.ESTestCase;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import static org.elasticsearch.geo.GeometryTestUtils.linearRing;
public class ShapeTestUtils {
    public static double randomValue() {
        return XShapeTestUtil.nextDouble();