Skip to content

Commit b2e4639

Browse files
authored
Move legacy geo_shape implementation to its own module (#77856)
This commit moves the legacy geo_shape implementation to its own module and removes the dependency on Spatial4J / JTS from server.
1 parent eeb09f0 commit b2e4639

File tree

75 files changed

+5398
-3450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+5398
-3450
lines changed

modules/legacy-geo/build.gradle

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
apply plugin: 'elasticsearch.internal-cluster-test'
10+
apply plugin: 'nebula.optional-base'
11+
12+
esplugin {
13+
description 'Placeholder plugin for geospatial features in ES'
14+
classname 'org.elasticsearch.legacygeo.LegacyGeoPlugin'
15+
}
16+
17+
dependencies {
18+
api "org.apache.lucene:lucene-spatial-extras:${versions.lucene}"
19+
api "org.locationtech.spatial4j:spatial4j:${versions.spatial4j}", optional
20+
api "org.locationtech.jts:jts-core:${versions.jts}", optional
21+
testImplementation project(":test:framework")
22+
}
23+
24+
tasks.named("thirdPartyAudit").configure {
25+
ignoreMissingClasses(
26+
27+
// from org.locationtech.spatial4j.io.GeoJSONReader (spatial4j)
28+
'org.noggit.JSONParser',
29+
30+
// from org.locationtech.spatial4j.io.jackson.ShapeAsGeoJSONSerialize
31+
'com.fasterxml.jackson.databind.JsonSerializer',
32+
'com.fasterxml.jackson.databind.JsonDeserializer',
33+
'com.fasterxml.jackson.databind.node.ArrayNode',
34+
'com.fasterxml.jackson.databind.DeserializationContext',
35+
'com.fasterxml.jackson.databind.JsonNode',
36+
'com.fasterxml.jackson.databind.SerializerProvider',
37+
'com.fasterxml.jackson.databind.module.SimpleModule',
38+
'com.fasterxml.jackson.databind.node.ObjectNode',
39+
40+
// from lucene-spatial
41+
'com.google.common.geometry.S2Cell',
42+
'com.google.common.geometry.S2CellId',
43+
'com.google.common.geometry.S2Projections',
44+
'com.google.common.geometry.S2Point',
45+
'com.google.common.geometry.S2$Metric',
46+
'com.google.common.geometry.S2LatLng'
47+
)
48+
}
49+
50+
tasks.named("dependencyLicenses").configure {
51+
mapping from: /lucene-.*/, to: 'lucene'
52+
}
53+

modules/legacy-geo/licenses/lucene-LICENSE.txt

Lines changed: 475 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
Apache Lucene
2+
Copyright 2014 The Apache Software Foundation
3+
4+
This product includes software developed at
5+
The Apache Software Foundation (http://www.apache.org/).
6+
7+
Includes software from other Apache Software Foundation projects,
8+
including, but not limited to:
9+
- Apache Ant
10+
- Apache Jakarta Regexp
11+
- Apache Commons
12+
- Apache Xerces
13+
14+
ICU4J, (under analysis/icu) is licensed under an MIT styles license
15+
and Copyright (c) 1995-2008 International Business Machines Corporation and others
16+
17+
Some data files (under analysis/icu/src/data) are derived from Unicode data such
18+
as the Unicode Character Database. See http://unicode.org/copyright.html for more
19+
details.
20+
21+
Brics Automaton (under core/src/java/org/apache/lucene/util/automaton) is
22+
BSD-licensed, created by Anders Møller. See http://www.brics.dk/automaton/
23+
24+
The levenshtein automata tables (under core/src/java/org/apache/lucene/util/automaton) were
25+
automatically generated with the moman/finenight FSA library, created by
26+
Jean-Philippe Barrette-LaPierre. This library is available under an MIT license,
27+
see http://sites.google.com/site/rrettesite/moman and
28+
http://bitbucket.org/jpbarrette/moman/overview/
29+
30+
The class org.apache.lucene.util.WeakIdentityMap was derived from
31+
the Apache CXF project and is Apache License 2.0.
32+
33+
The Google Code Prettify is Apache License 2.0.
34+
See http://code.google.com/p/google-code-prettify/
35+
36+
JUnit (junit-4.10) is licensed under the Common Public License v. 1.0
37+
See http://junit.sourceforge.net/cpl-v10.html
38+
39+
This product includes code (JaspellTernarySearchTrie) from Java Spelling Checkin
40+
g Package (jaspell): http://jaspell.sourceforge.net/
41+
License: The BSD License (http://www.opensource.org/licenses/bsd-license.php)
42+
43+
The snowball stemmers in
44+
analysis/common/src/java/net/sf/snowball
45+
were developed by Martin Porter and Richard Boulton.
46+
The snowball stopword lists in
47+
analysis/common/src/resources/org/apache/lucene/analysis/snowball
48+
were developed by Martin Porter and Richard Boulton.
49+
The full snowball package is available from
50+
http://snowball.tartarus.org/
51+
52+
The KStem stemmer in
53+
analysis/common/src/org/apache/lucene/analysis/en
54+
was developed by Bob Krovetz and Sergio Guzman-Lara (CIIR-UMass Amherst)
55+
under the BSD-license.
56+
57+
The Arabic,Persian,Romanian,Bulgarian, Hindi and Bengali analyzers (common) come with a default
58+
stopword list that is BSD-licensed created by Jacques Savoy. These files reside in:
59+
analysis/common/src/resources/org/apache/lucene/analysis/ar/stopwords.txt,
60+
analysis/common/src/resources/org/apache/lucene/analysis/fa/stopwords.txt,
61+
analysis/common/src/resources/org/apache/lucene/analysis/ro/stopwords.txt,
62+
analysis/common/src/resources/org/apache/lucene/analysis/bg/stopwords.txt,
63+
analysis/common/src/resources/org/apache/lucene/analysis/hi/stopwords.txt,
64+
analysis/common/src/resources/org/apache/lucene/analysis/bn/stopwords.txt
65+
See http://members.unine.ch/jacques.savoy/clef/index.html.
66+
67+
The German,Spanish,Finnish,French,Hungarian,Italian,Portuguese,Russian and Swedish light stemmers
68+
(common) are based on BSD-licensed reference implementations created by Jacques Savoy and
69+
Ljiljana Dolamic. These files reside in:
70+
analysis/common/src/java/org/apache/lucene/analysis/de/GermanLightStemmer.java
71+
analysis/common/src/java/org/apache/lucene/analysis/de/GermanMinimalStemmer.java
72+
analysis/common/src/java/org/apache/lucene/analysis/es/SpanishLightStemmer.java
73+
analysis/common/src/java/org/apache/lucene/analysis/fi/FinnishLightStemmer.java
74+
analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchLightStemmer.java
75+
analysis/common/src/java/org/apache/lucene/analysis/fr/FrenchMinimalStemmer.java
76+
analysis/common/src/java/org/apache/lucene/analysis/hu/HungarianLightStemmer.java
77+
analysis/common/src/java/org/apache/lucene/analysis/it/ItalianLightStemmer.java
78+
analysis/common/src/java/org/apache/lucene/analysis/pt/PortugueseLightStemmer.java
79+
analysis/common/src/java/org/apache/lucene/analysis/ru/RussianLightStemmer.java
80+
analysis/common/src/java/org/apache/lucene/analysis/sv/SwedishLightStemmer.java
81+
82+
The Stempel analyzer (stempel) includes BSD-licensed software developed
83+
by the Egothor project http://egothor.sf.net/, created by Leo Galambos, Martin Kvapil,
84+
and Edmond Nolan.
85+
86+
The Polish analyzer (stempel) comes with a default
87+
stopword list that is BSD-licensed created by the Carrot2 project. The file resides
88+
in stempel/src/resources/org/apache/lucene/analysis/pl/stopwords.txt.
89+
See http://project.carrot2.org/license.html.
90+
91+
The SmartChineseAnalyzer source code (smartcn) was
92+
provided by Xiaoping Gao and copyright 2009 by www.imdict.net.
93+
94+
WordBreakTestUnicode_*.java (under modules/analysis/common/src/test/)
95+
is derived from Unicode data such as the Unicode Character Database.
96+
See http://unicode.org/copyright.html for more details.
97+
98+
The Morfologik analyzer (morfologik) includes BSD-licensed software
99+
developed by Dawid Weiss and Marcin Miłkowski (http://morfologik.blogspot.com/).
100+
101+
Morfologik uses data from Polish ispell/myspell dictionary
102+
(http://www.sjp.pl/slownik/en/) licenced on the terms of (inter alia)
103+
LGPL and Creative Commons ShareAlike.
104+
105+
Morfologic includes data from BSD-licensed dictionary of Polish (SGJP)
106+
(http://sgjp.pl/morfeusz/)
107+
108+
Servlet-api.jar and javax.servlet-*.jar are under the CDDL license, the original
109+
source code for this can be found at http://www.eclipse.org/jetty/downloads.php
110+
111+
===========================================================================
112+
Kuromoji Japanese Morphological Analyzer - Apache Lucene Integration
113+
===========================================================================
114+
115+
This software includes a binary and/or source version of data from
116+
117+
mecab-ipadic-2.7.0-20070801
118+
119+
which can be obtained from
120+
121+
http://atilika.com/releases/mecab-ipadic/mecab-ipadic-2.7.0-20070801.tar.gz
122+
123+
or
124+
125+
http://jaist.dl.sourceforge.net/project/mecab/mecab-ipadic/2.7.0-20070801/mecab-ipadic-2.7.0-20070801.tar.gz
126+
127+
===========================================================================
128+
mecab-ipadic-2.7.0-20070801 Notice
129+
===========================================================================
130+
131+
Nara Institute of Science and Technology (NAIST),
132+
the copyright holders, disclaims all warranties with regard to this
133+
software, including all implied warranties of merchantability and
134+
fitness, in no event shall NAIST be liable for
135+
any special, indirect or consequential damages or any damages
136+
whatsoever resulting from loss of use, data or profits, whether in an
137+
action of contract, negligence or other tortuous action, arising out
138+
of or in connection with the use or performance of this software.
139+
140+
A large portion of the dictionary entries
141+
originate from ICOT Free Software. The following conditions for ICOT
142+
Free Software applies to the current dictionary as well.
143+
144+
Each User may also freely distribute the Program, whether in its
145+
original form or modified, to any third party or parties, PROVIDED
146+
that the provisions of Section 3 ("NO WARRANTY") will ALWAYS appear
147+
on, or be attached to, the Program, which is distributed substantially
148+
in the same form as set out herein and that such intended
149+
distribution, if actually made, will neither violate or otherwise
150+
contravene any of the laws and regulations of the countries having
151+
jurisdiction over the User or the intended distribution itself.
152+
153+
NO WARRANTY
154+
155+
The program was produced on an experimental basis in the course of the
156+
research and development conducted during the project and is provided
157+
to users as so produced on an experimental basis. Accordingly, the
158+
program is provided without any warranty whatsoever, whether express,
159+
implied, statutory or otherwise. The term "warranty" used herein
160+
includes, but is not limited to, any warranty of the quality,
161+
performance, merchantability and fitness for a particular purpose of
162+
the program and the nonexistence of any infringement or violation of
163+
any right of any third party.
164+
165+
Each user of the program will agree and understand, and be deemed to
166+
have agreed and understood, that there is no warranty whatsoever for
167+
the program and, accordingly, the entire risk arising from or
168+
otherwise connected with the program is assumed by the user.
169+
170+
Therefore, neither ICOT, the copyright holder, or any other
171+
organization that participated in or was otherwise related to the
172+
development of the program and their respective officials, directors,
173+
officers and other employees shall be held liable for any and all
174+
damages, including, without limitation, general, special, incidental
175+
and consequential damages, arising out of or otherwise in connection
176+
with the use or inability to use the program or any product, material
177+
or result produced or otherwise obtained by using the program,
178+
regardless of whether they have been advised of, or otherwise had
179+
knowledge of, the possibility of such damages at any time during the
180+
project or thereafter. Each user will be deemed to have agreed to the
181+
foregoing by his or her commencement of use of the program. The term
182+
"use" as used herein includes, but is not limited to, the use,
183+
modification, copying and distribution of the program and the
184+
production of secondary products from the program.
185+
186+
In the case where the program, whether in its original form or
187+
modified, was distributed or delivered to or received by a user from
188+
any person, organization or entity other than ICOT, unless it makes or
189+
grants independently of ICOT any specific warranty to the user in
190+
writing, such person, organization or entity, will also be exempted
191+
from and not be held liable to the user for any such damages as noted
192+
above as far as the program is concerned.

server/src/internalClusterTest/java/org/elasticsearch/search/geo/GeoBoundingBoxQueryLegacyGeoShapeIT.java renamed to modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/GeoBoundingBoxQueryLegacyGeoShapeIT.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@
66
* Side Public License, v 1.
77
*/
88

9-
package org.elasticsearch.search.geo;
9+
package org.elasticsearch.legacygeo.search;
1010

1111
import org.elasticsearch.Version;
1212
import org.elasticsearch.common.xcontent.XContentBuilder;
1313
import org.elasticsearch.common.xcontent.XContentFactory;
14+
import org.elasticsearch.legacygeo.test.TestLegacyGeoShapeFieldMapperPlugin;
1415
import org.elasticsearch.plugins.Plugin;
15-
import org.elasticsearch.test.TestLegacyGeoShapeFieldMapperPlugin;
16+
import org.elasticsearch.search.geo.GeoBoundingBoxQueryIntegTestCase;
1617
import org.elasticsearch.test.VersionUtils;
1718

1819
import java.io.IOException;
@@ -33,14 +34,21 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
3334

3435
@Override
3536
public XContentBuilder getMapping() throws IOException {
36-
return XContentFactory.jsonBuilder().startObject().startObject("_doc")
37-
.startObject("properties").startObject("location").field("type", "geo_shape").field("strategy", "recursive")
38-
.endObject().endObject().endObject().endObject();
37+
return XContentFactory.jsonBuilder()
38+
.startObject()
39+
.startObject("_doc")
40+
.startObject("properties")
41+
.startObject("location")
42+
.field("type", "geo_shape")
43+
.field("strategy", "recursive")
44+
.endObject()
45+
.endObject()
46+
.endObject()
47+
.endObject();
3948
}
4049

4150
@Override
4251
public Version randomSupportedVersion() {
4352
return VersionUtils.randomIndexCompatibleVersion(random());
4453
}
4554
}
46-

server/src/internalClusterTest/java/org/elasticsearch/search/geo/LegacyGeoShapeIT.java renamed to modules/legacy-geo/src/internalClusterTest/java/org/elasticsearch/legacygeo/search/LegacyGeoShapeIT.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
* Side Public License, v 1.
77
*/
88

9-
package org.elasticsearch.search.geo;
9+
package org.elasticsearch.legacygeo.search;
1010

1111
import org.elasticsearch.Version;
1212
import org.elasticsearch.action.search.SearchResponse;
1313
import org.elasticsearch.common.xcontent.ToXContent;
1414
import org.elasticsearch.common.xcontent.XContentBuilder;
1515
import org.elasticsearch.geometry.Circle;
16+
import org.elasticsearch.legacygeo.test.TestLegacyGeoShapeFieldMapperPlugin;
1617
import org.elasticsearch.plugins.Plugin;
17-
import org.elasticsearch.test.TestLegacyGeoShapeFieldMapperPlugin;
18+
import org.elasticsearch.search.geo.GeoShapeIntegTestCase;
1819
import org.elasticsearch.test.VersionUtils;
1920

2021
import java.io.IOException;
@@ -58,21 +59,27 @@ protected boolean allowExpensiveQueries() {
5859
*/
5960
public void testLegacyCircle() throws Exception {
6061
// create index
61-
assertAcked(prepareCreate("test").setSettings(settings(randomSupportedVersion()).build())
62-
.setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash").get());
62+
assertAcked(
63+
prepareCreate("test").setSettings(settings(randomSupportedVersion()).build())
64+
.setMapping("shape", "type=geo_shape,strategy=recursive,tree=geohash")
65+
.get()
66+
);
6367
ensureGreen();
6468

6569
indexRandom(true, client().prepareIndex("test").setId("0").setSource("shape", (ToXContent) (builder, params) -> {
66-
builder.startObject().field("type", "circle")
67-
.startArray("coordinates").value(30).value(50).endArray()
68-
.field("radius","77km")
70+
builder.startObject()
71+
.field("type", "circle")
72+
.startArray("coordinates")
73+
.value(30)
74+
.value(50)
75+
.endArray()
76+
.field("radius", "77km")
6977
.endObject();
7078
return builder;
7179
}));
7280

7381
// test self crossing of circles
74-
SearchResponse searchResponse = client().prepareSearch("test").setQuery(geoShapeQuery("shape",
75-
new Circle(30, 50, 77000))).get();
82+
SearchResponse searchResponse = client().prepareSearch("test").setQuery(geoShapeQuery("shape", new Circle(30, 50, 77000))).get();
7683
assertThat(searchResponse.getHits().getTotalHits().value, equalTo(1L));
7784
}
7885
}

0 commit comments

Comments
 (0)