Search in sources :

Example 6 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class GeoDistanceIT method testDistanceSortingWithMissingGeoPoint.

// Regression bug:
// https://github.com/elastic/elasticsearch/issues/2851
public void testDistanceSortingWithMissingGeoPoint() throws Exception {
    Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("locations").field("type", "geo_point");
    xContentBuilder.endObject().endObject().endObject().endObject();
    assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
    ensureGreen();
    client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().array("names", "Times Square", "Tribeca").startArray("locations").startObject().field("lat", 40.759011).field("lon", -73.9844722).endObject().startObject().field("lat", 40.718266).field("lon", -74.007819).endObject().endArray().endObject()).execute().actionGet();
    client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject().array("names", "Wall Street", "Soho").endObject()).execute().actionGet();
    refresh();
    // Order: Asc
    SearchResponse searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.ASC)).execute().actionGet();
    assertHitCount(searchResponse, 2);
    assertOrderedSearchHits(searchResponse, "1", "2");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), closeTo(462.1d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), equalTo(Double.POSITIVE_INFINITY));
    // Order: Desc
    searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.DESC)).execute().actionGet();
    // Doc with missing geo point is first, is consistent with 0.20.x
    assertHitCount(searchResponse, 2);
    assertOrderedSearchHits(searchResponse, "2", "1");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), equalTo(Double.POSITIVE_INFINITY));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(5286d, 10d));
}
Also used : Version(org.elasticsearch.Version) Settings(org.elasticsearch.common.settings.Settings) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 7 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class GeoDistanceIT method testDistanceSortingMVFields.

public void testDistanceSortingMVFields() throws Exception {
    Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    XContentBuilder xContentBuilder = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("locations").field("type", "geo_point");
    xContentBuilder.field("ignore_malformed", true).endObject().endObject().endObject().endObject();
    assertAcked(prepareCreate("test").setSettings(settings).addMapping("type1", xContentBuilder));
    ensureGreen();
    client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject().field("names", "New York").startObject("locations").field("lat", 40.7143528).field("lon", -74.0059731).endObject().endObject()).execute().actionGet();
    client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject().field("names", "New York 2").startObject("locations").field("lat", 400.7143528).field("lon", 285.9990269).endObject().endObject()).execute().actionGet();
    client().prepareIndex("test", "type1", "3").setSource(jsonBuilder().startObject().array("names", "Times Square", "Tribeca").startArray("locations").startObject().field("lat", 40.759011).field("lon", -73.9844722).endObject().startObject().field("lat", 40.718266).field("lon", -74.007819).endObject().endArray().endObject()).execute().actionGet();
    client().prepareIndex("test", "type1", "4").setSource(jsonBuilder().startObject().array("names", "Wall Street", "Soho").startArray("locations").startObject().field("lat", 40.7051157).field("lon", -74.0088305).endObject().startObject().field("lat", 40.7247222).field("lon", -74).endObject().endArray().endObject()).execute().actionGet();
    client().prepareIndex("test", "type1", "5").setSource(jsonBuilder().startObject().array("names", "Greenwich Village", "Brooklyn").startArray("locations").startObject().field("lat", 40.731033).field("lon", -73.9962255).endObject().startObject().field("lat", 40.65).field("lon", -73.95).endObject().endArray().endObject()).execute().actionGet();
    client().admin().indices().prepareRefresh().execute().actionGet();
    // Order: Asc
    SearchResponse searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.ASC)).execute().actionGet();
    assertHitCount(searchResponse, 5);
    assertOrderedSearchHits(searchResponse, "1", "2", "3", "4", "5");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), closeTo(0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(421.2d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), closeTo(462.1d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(3).getSortValues()[0]).doubleValue(), closeTo(1055.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(4).getSortValues()[0]).doubleValue(), closeTo(2029.0d, 10d));
    // Order: Asc, Mode: max
    searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.ASC).sortMode(SortMode.MAX)).execute().actionGet();
    assertHitCount(searchResponse, 5);
    assertOrderedSearchHits(searchResponse, "1", "2", "4", "3", "5");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), closeTo(0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(421.2d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), closeTo(1258.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(3).getSortValues()[0]).doubleValue(), closeTo(5286.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(4).getSortValues()[0]).doubleValue(), closeTo(8572.0d, 10d));
    // Order: Desc
    searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.DESC)).execute().actionGet();
    assertHitCount(searchResponse, 5);
    assertOrderedSearchHits(searchResponse, "5", "3", "4", "2", "1");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), closeTo(8572.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(5286.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), closeTo(1258.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(3).getSortValues()[0]).doubleValue(), closeTo(421.2d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(4).getSortValues()[0]).doubleValue(), closeTo(0d, 10d));
    // Order: Desc, Mode: min
    searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).order(SortOrder.DESC).sortMode(SortMode.MIN)).execute().actionGet();
    assertHitCount(searchResponse, 5);
    assertOrderedSearchHits(searchResponse, "5", "4", "3", "2", "1");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), closeTo(2029.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(1055.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), closeTo(462.1d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(3).getSortValues()[0]).doubleValue(), closeTo(421.2d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(4).getSortValues()[0]).doubleValue(), closeTo(0d, 10d));
    searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode(SortMode.AVG).order(SortOrder.ASC)).execute().actionGet();
    assertHitCount(searchResponse, 5);
    assertOrderedSearchHits(searchResponse, "1", "2", "4", "3", "5");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), closeTo(0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(421.2d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), closeTo(1157d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(3).getSortValues()[0]).doubleValue(), closeTo(2874d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(4).getSortValues()[0]).doubleValue(), closeTo(5301d, 10d));
    searchResponse = client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode(SortMode.AVG).order(SortOrder.DESC)).execute().actionGet();
    assertHitCount(searchResponse, 5);
    assertOrderedSearchHits(searchResponse, "5", "3", "4", "2", "1");
    assertThat(((Number) searchResponse.getHits().getAt(0).getSortValues()[0]).doubleValue(), closeTo(5301.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(1).getSortValues()[0]).doubleValue(), closeTo(2874.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(2).getSortValues()[0]).doubleValue(), closeTo(1157.0d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(3).getSortValues()[0]).doubleValue(), closeTo(421.2d, 10d));
    assertThat(((Number) searchResponse.getHits().getAt(4).getSortValues()[0]).doubleValue(), closeTo(0d, 10d));
    try {
        client().prepareSearch("test").setQuery(matchAllQuery()).addSort(SortBuilders.geoDistanceSort("locations", 40.7143528, -74.0059731).sortMode(SortMode.SUM));
        fail("sum should not be supported for sorting by geo distance");
    } catch (IllegalArgumentException e) {
    // expected
    }
}
Also used : Version(org.elasticsearch.Version) Settings(org.elasticsearch.common.settings.Settings) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 8 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class GeoDistanceSortBuilderIT method testManyToManyGeoPoints.

public void testManyToManyGeoPoints() throws ExecutionException, InterruptedException, IOException {
    /**
         * | q  |  d1    |   d2
         * |    |        |
         * |    |        |
         * |    |        |
         * |2  o|  x     |     x
         * |    |        |
         * |1  o|      x | x
         * |___________________________
         * 1   2   3   4   5   6   7
         */
    Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point"));
    XContentBuilder d1Builder = jsonBuilder();
    GeoPoint[] d1Points = { new GeoPoint(3, 2), new GeoPoint(4, 1) };
    createShuffeldJSONArray(d1Builder, d1Points);
    XContentBuilder d2Builder = jsonBuilder();
    GeoPoint[] d2Points = { new GeoPoint(5, 1), new GeoPoint(6, 2) };
    createShuffeldJSONArray(d2Builder, d2Points);
    logger.info("d1: {}", d1Builder);
    logger.info("d2: {}", d2Builder);
    indexRandom(true, client().prepareIndex("index", "type", "d1").setSource(d1Builder), client().prepareIndex("index", "type", "d2").setSource(d2Builder));
    GeoPoint[] q = new GeoPoint[2];
    if (randomBoolean()) {
        q[0] = new GeoPoint(2, 1);
        q[1] = new GeoPoint(2, 2);
    } else {
        q[1] = new GeoPoint(2, 2);
        q[0] = new GeoPoint(2, 1);
    }
    SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MIN).order(SortOrder.ASC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d1", "d2");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 2, 3, 2, DistanceUnit.METERS), 10d));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 1, 5, 1, DistanceUnit.METERS), 10d));
    searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MIN).order(SortOrder.DESC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d2", "d1");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 1, 5, 1, DistanceUnit.METERS), 10d));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 2, 3, 2, DistanceUnit.METERS), 10d));
    searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MAX).order(SortOrder.ASC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d1", "d2");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 2, 4, 1, DistanceUnit.METERS), 10d));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 1, 6, 2, DistanceUnit.METERS), 10d));
    searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MAX).order(SortOrder.DESC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d2", "d1");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 1, 6, 2, DistanceUnit.METERS), 10d));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2, 2, 4, 1, DistanceUnit.METERS), 10d));
}
Also used : GeoPoint(org.elasticsearch.common.geo.GeoPoint) Version(org.elasticsearch.Version) Settings(org.elasticsearch.common.settings.Settings) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 9 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class GeoDistanceSortBuilderIT method testSingeToManyAvgMedian.

public void testSingeToManyAvgMedian() throws ExecutionException, InterruptedException, IOException {
    /**
         * q  = (0, 0)
         *
         * d1 = (0, 1), (0, 4), (0, 10); so avg. distance is 5, median distance is 4
         * d2 = (0, 1), (0, 5), (0, 6); so avg. distance is 4, median distance is 5
         */
    Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point"));
    XContentBuilder d1Builder = jsonBuilder();
    GeoPoint[] d1Points = { new GeoPoint(0, 1), new GeoPoint(0, 4), new GeoPoint(0, 10) };
    createShuffeldJSONArray(d1Builder, d1Points);
    XContentBuilder d2Builder = jsonBuilder();
    GeoPoint[] d2Points = { new GeoPoint(0, 1), new GeoPoint(0, 5), new GeoPoint(0, 6) };
    createShuffeldJSONArray(d2Builder, d2Points);
    logger.info("d1: {}", d1Builder);
    logger.info("d2: {}", d2Builder);
    indexRandom(true, client().prepareIndex("index", "type", "d1").setSource(d1Builder), client().prepareIndex("index", "type", "d2").setSource(d2Builder));
    GeoPoint q = new GeoPoint(0, 0);
    SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.AVG).order(SortOrder.ASC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d2", "d1");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(0, 0, 0, 4, DistanceUnit.METERS), 10d));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(0, 0, 0, 5, DistanceUnit.METERS), 10d));
    searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(new GeoDistanceSortBuilder(LOCATION_FIELD, q).sortMode(SortMode.MEDIAN).order(SortOrder.ASC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d1", "d2");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(0, 0, 0, 4, DistanceUnit.METERS), 10d));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(0, 0, 0, 5, DistanceUnit.METERS), 10d));
}
Also used : GeoPoint(org.elasticsearch.common.geo.GeoPoint) Version(org.elasticsearch.Version) Settings(org.elasticsearch.common.settings.Settings) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Example 10 with Version

use of org.elasticsearch.Version in project elasticsearch by elastic.

the class GeoDistanceSortBuilderIT method testManyToManyGeoPointsWithDifferentFormats.

public void testManyToManyGeoPointsWithDifferentFormats() throws ExecutionException, InterruptedException, IOException {
    /**   q     d1       d2
         * |4  o|   x    |   x
         * |    |        |
         * |3  o|  x     |  x
         * |    |        |
         * |2  o| x      | x
         * |    |        |
         * |1  o|x       |x
         * |______________________
         * 1   2   3   4   5   6
         */
    Version version = randomBoolean() ? Version.CURRENT : VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
    Settings settings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
    assertAcked(prepareCreate("index").setSettings(settings).addMapping("type", LOCATION_FIELD, "type=geo_point"));
    XContentBuilder d1Builder = jsonBuilder();
    GeoPoint[] d1Points = { new GeoPoint(2.5, 1), new GeoPoint(2.75, 2), new GeoPoint(3, 3), new GeoPoint(3.25, 4) };
    createShuffeldJSONArray(d1Builder, d1Points);
    XContentBuilder d2Builder = jsonBuilder();
    GeoPoint[] d2Points = { new GeoPoint(4.5, 1), new GeoPoint(4.75, 2), new GeoPoint(5, 3), new GeoPoint(5.25, 4) };
    createShuffeldJSONArray(d2Builder, d2Points);
    indexRandom(true, client().prepareIndex("index", "type", "d1").setSource(d1Builder), client().prepareIndex("index", "type", "d2").setSource(d2Builder));
    List<String> qHashes = new ArrayList<>();
    List<GeoPoint> qPoints = new ArrayList<>();
    createQPoints(qHashes, qPoints);
    GeoDistanceSortBuilder geoDistanceSortBuilder = null;
    for (int i = 0; i < 4; i++) {
        int at = randomInt(3 - i);
        if (randomBoolean()) {
            if (geoDistanceSortBuilder == null) {
                geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, qHashes.get(at));
            } else {
                geoDistanceSortBuilder.geohashes(qHashes.get(at));
            }
        } else {
            if (geoDistanceSortBuilder == null) {
                geoDistanceSortBuilder = new GeoDistanceSortBuilder(LOCATION_FIELD, qPoints.get(at));
            } else {
                geoDistanceSortBuilder.points(qPoints.get(at));
            }
        }
        qHashes.remove(at);
        qPoints.remove(at);
    }
    SearchResponse searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(geoDistanceSortBuilder.sortMode(SortMode.MIN).order(SortOrder.ASC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d1", "d2");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(2.5, 1, 2, 1, DistanceUnit.METERS), 1.e-1));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(4.5, 1, 2, 1, DistanceUnit.METERS), 1.e-1));
    searchResponse = client().prepareSearch().setQuery(matchAllQuery()).addSort(geoDistanceSortBuilder.sortMode(SortMode.MAX).order(SortOrder.ASC)).execute().actionGet();
    assertOrderedSearchHits(searchResponse, "d1", "d2");
    assertThat((Double) searchResponse.getHits().getAt(0).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(3.25, 4, 2, 1, DistanceUnit.METERS), 1.e-1));
    assertThat((Double) searchResponse.getHits().getAt(1).getSortValues()[0], closeTo(GeoDistance.ARC.calculate(5.25, 4, 2, 1, DistanceUnit.METERS), 1.e-1));
}
Also used : GeoPoint(org.elasticsearch.common.geo.GeoPoint) Version(org.elasticsearch.Version) ArrayList(java.util.ArrayList) Settings(org.elasticsearch.common.settings.Settings) XContentBuilder(org.elasticsearch.common.xcontent.XContentBuilder) GeoPoint(org.elasticsearch.common.geo.GeoPoint) SearchResponse(org.elasticsearch.action.search.SearchResponse)

Aggregations

Version (org.elasticsearch.Version)124 Settings (org.elasticsearch.common.settings.Settings)51 StreamInput (org.elasticsearch.common.io.stream.StreamInput)21 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)20 HashMap (java.util.HashMap)17 ArrayList (java.util.ArrayList)16 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)16 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)14 IOException (java.io.IOException)13 SearchResponse (org.elasticsearch.action.search.SearchResponse)12 List (java.util.List)11 Map (java.util.Map)11 ClusterState (org.elasticsearch.cluster.ClusterState)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 ClusterName (org.elasticsearch.cluster.ClusterName)9 TimeValue (org.elasticsearch.common.unit.TimeValue)9 VersionUtils.randomVersion (org.elasticsearch.test.VersionUtils.randomVersion)9 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)8 CompressedXContent (org.elasticsearch.common.compress.CompressedXContent)8 GeoPoint (org.elasticsearch.common.geo.GeoPoint)8