Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GeoShape tests to GeoShape and GeoPoint #50737

Merged
merged 23 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a5f09fb
WIP subclassing GeoShapeQueryTests.java
Nov 15, 2019
478cee7
WIP subclassing GeoShapeQueryTests.java
Nov 18, 2019
ebd06e4
WIP subclassing GeoShapeQueryTests.java
Nov 19, 2019
5d3c189
WIP writing GeoPointShapeQueryTests.java
Nov 19, 2019
ab60f06
Added Failing Test testIndexPointsFilterRectangle
Nov 20, 2019
c22308f
Merge branch 'master' into geo-shape-query-vs-geo-point
Nov 20, 2019
443441c
Merge branch 'master' into geo-shape-query-vs-geo-point
Nov 21, 2019
24b9535
permit GeoShapeQueryBuilder to accept a geo_point -> class_cast_excep…
Nov 23, 2019
59c1bfc
added @Override protected XContentBuilder createMapping
Dec 2, 2019
192ad15
merged upstream including 418edc6 types fixes
Jan 7, 2020
ddc9e8c
repeat refactor post type removal and remove remaining types from Geo…
Jan 7, 2020
0f3bd91
tidy GeoPointShapeQueryTests.java
Jan 7, 2020
6d68e7f
interim checkin, still failing tests
Jan 8, 2020
2d880c2
GeoShapeQueryTests.java passing tests
Jan 8, 2020
e275f3e
GeoShapeQueryTests.java extends GeoQueryTests
Jan 8, 2020
316c7b1
refactored + tests passing
Jan 8, 2020
e7e5e7b
refactored + tests passing
Jan 8, 2020
d7f2218
reset GeoShapeQueryBuilder.java for future PR
Jan 8, 2020
e54c867
improved refactoring see: https://github.com/elastic/elasticsearch/pu…
Jan 9, 2020
9025578
refactor
Jan 14, 2020
13e8b00
Merge branch 'djptek-geo-shape-query-vs-geo-point'
Jan 24, 2020
83504d1
merged refactor changes to upstream
Jan 24, 2020
4d3676b
rectified Checkstyle rule violations
Jan 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.search.geo;

import org.elasticsearch.common.Strings;
import org.elasticsearch.common.geo.builders.*;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.locationtech.jts.geom.Coordinate;

import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;

public class GeoPointShapeQueryTests extends GeoQueryTests {

@Override
protected XContentBuilder createMapping() throws Exception {
XContentBuilder xcb = XContentFactory.jsonBuilder().startObject()
.startObject("properties").startObject("location")
.field("type", "geo_point")
.endObject().endObject().endObject();

return xcb;
}

djptek marked this conversation as resolved.
Show resolved Hide resolved
public void testIndexPointsFilterRectangle() throws Exception {
String mapping = Strings.toString(createMapping());
// where does the mapping ensure geo_shape type for the location field, a template?
client().admin().indices().prepareCreate("test").setMapping(mapping).get();
ensureGreen();

client().prepareIndex("test").setId("1").setSource(jsonBuilder().startObject()
.field("name", "Document 1")
.startArray("location").value(-30).value(-30).endArray()
.endObject()).setRefreshPolicy(IMMEDIATE).get();

client().prepareIndex("test").setId("2").setSource(jsonBuilder().startObject()
.field("name", "Document 2")
.startArray("location").value(-45).value(-50).endArray()
.endObject()).setRefreshPolicy(IMMEDIATE).get();

EnvelopeBuilder shape = new EnvelopeBuilder(new Coordinate(-45, 45), new Coordinate(45, -45));

// Pending new query processor for lat lon point queries + new code for geo shape field mapper

/*
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(geoShapeQuery("location", shape))
.get();

assertSearchResponse(searchResponse);

assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
assertThat(searchResponse.getHits().getHits().length, equalTo(1));
assertThat(searchResponse.getHits().getAt(0).getId(), equalTo("1"));
*/

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.search.geo;

import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.mapper.LegacyGeoShapeFieldMapper;
import org.elasticsearch.test.ESSingleNodeTestCase;

public abstract class GeoQueryTests extends ESSingleNodeTestCase {
protected static final String[] PREFIX_TREES = new String[] {
LegacyGeoShapeFieldMapper.DeprecatedParameters.PrefixTrees.GEOHASH,
LegacyGeoShapeFieldMapper.DeprecatedParameters.PrefixTrees.QUADTREE
};

protected abstract XContentBuilder createMapping() throws Exception;

}
Loading