Search in sources :

Example 11 with MultiLine

use of org.opensearch.geometry.MultiLine in project OpenSearch by opensearch-project.

the class GeoPointShapeQueryTests method testQueryMultiLine.

public void testQueryMultiLine() throws Exception {
    XContentBuilder xcb = createDefaultMapping();
    client().admin().indices().prepareCreate("test").addMapping("_doc", xcb).get();
    ensureGreen();
    CoordinatesBuilder coords1 = new CoordinatesBuilder().coordinate(-35, -35).coordinate(-25, -25);
    CoordinatesBuilder coords2 = new CoordinatesBuilder().coordinate(-15, -15).coordinate(-5, -5);
    LineStringBuilder lsb1 = new LineStringBuilder(coords1);
    LineStringBuilder lsb2 = new LineStringBuilder(coords2);
    MultiLineStringBuilder mlb = new MultiLineStringBuilder().linestring(lsb1).linestring(lsb2);
    MultiLine multiline = (MultiLine) mlb.buildGeometry();
    try {
        client().prepareSearch("test").setQuery(QueryBuilders.geoShapeQuery(defaultGeoFieldName, multiline)).get();
    } catch (Exception e) {
        assertThat(e.getCause().getMessage(), containsString("does not support " + GeoShapeType.MULTILINESTRING + " queries"));
    }
}
Also used : MultiLine(org.opensearch.geometry.MultiLine) CoordinatesBuilder(org.opensearch.common.geo.builders.CoordinatesBuilder) MultiLineStringBuilder(org.opensearch.common.geo.builders.MultiLineStringBuilder) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) MultiLineStringBuilder(org.opensearch.common.geo.builders.MultiLineStringBuilder) LineStringBuilder(org.opensearch.common.geo.builders.LineStringBuilder) SearchPhaseExecutionException(org.opensearch.action.search.SearchPhaseExecutionException)

Aggregations

MultiLine (org.opensearch.geometry.MultiLine)11 Line (org.opensearch.geometry.Line)10 XContentBuilder (org.opensearch.common.xcontent.XContentBuilder)5 Geometry (org.opensearch.geometry.Geometry)5 MultiPoint (org.opensearch.geometry.MultiPoint)5 ArrayList (java.util.ArrayList)4 Coordinate (org.locationtech.jts.geom.Coordinate)3 Point (org.opensearch.geometry.Point)3 IOException (java.io.IOException)2 List (java.util.List)2 LineString (org.locationtech.jts.geom.LineString)2 MultiLineString (org.locationtech.jts.geom.MultiLineString)2 CoordinatesBuilder (org.opensearch.common.geo.builders.CoordinatesBuilder)2 LineStringBuilder (org.opensearch.common.geo.builders.LineStringBuilder)2 MultiLineStringBuilder (org.opensearch.common.geo.builders.MultiLineStringBuilder)2 ParseException (java.text.ParseException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 Objects (java.util.Objects)1