mirror of https://github.com/apache/lucene.git
SOLR-6904: remove deprecated spatial Circle & Rect syntax
FYI these weren't used often and were replaced with supported syntaxes in v4.3. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1651351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2b1d34dfd9
commit
c0707926df
|
@ -153,6 +153,11 @@ Upgrading from Solr 4.x
|
|||
solrconfig.xml. Solr defaults to using NRT searchers regardless of the value in configuration
|
||||
and a warning is logged on startup if the solrconfig.xml has <nrtMode> specified.
|
||||
|
||||
* There was an old spatial syntax to specify a circle using Circle(x,y d=...) which should be
|
||||
replaced with simply using {!geofilt} (if you can) or BUFFER(POINT(x y),d). Likewise a rect syntax
|
||||
comprised of minX minY maxX maxY that should now be replaced with
|
||||
ENVELOPE(minX, maxX, maxY, minY).
|
||||
|
||||
Detailed Change List
|
||||
----------------------
|
||||
|
||||
|
@ -684,6 +689,8 @@ Other Changes
|
|||
* SOLR-6496: LBHttpSolrClient stops server retries after the timeAllowed threshold is met.
|
||||
(Steve Davids, Anshum Gupta)
|
||||
|
||||
* SOLR-6904: Removed deprecated Circle & rect syntax. See upgrading notes. (David Smiley)
|
||||
|
||||
================== 4.10.3 ==================
|
||||
|
||||
Bug Fixes
|
||||
|
|
|
@ -23,7 +23,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
@ -36,7 +35,6 @@ import com.google.common.cache.CacheBuilder;
|
|||
import com.spatial4j.core.context.SpatialContext;
|
||||
import com.spatial4j.core.context.SpatialContextFactory;
|
||||
import com.spatial4j.core.distance.DistanceUtils;
|
||||
import com.spatial4j.core.io.LegacyShapeReadWriterFormat;
|
||||
import com.spatial4j.core.shape.Point;
|
||||
import com.spatial4j.core.shape.Rectangle;
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
|
@ -115,17 +113,6 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
|
|||
protected void init(IndexSchema schema, Map<String, String> args) {
|
||||
super.init(schema, args);
|
||||
|
||||
//replace legacy rect format with ENVELOPE
|
||||
String wbStr = args.get("worldBounds");
|
||||
if (wbStr != null && !wbStr.toUpperCase(Locale.ROOT).startsWith("ENVELOPE")) {
|
||||
log.warn("Using old worldBounds format? Should use ENVELOPE(xMin, xMax, yMax, yMin).");
|
||||
String[] parts = wbStr.split(" ");//"xMin yMin xMax yMax"
|
||||
if (parts.length == 4) {
|
||||
args.put("worldBounds",
|
||||
"ENVELOPE(" + parts[0] + ", " + parts[2] + ", " + parts[3] + ", " + parts[1] + ")");
|
||||
} //else likely eventual exception
|
||||
}
|
||||
|
||||
//Solr expects us to remove the parameters we've used.
|
||||
MapListener<String, String> argsWrap = new MapListener<>(args);
|
||||
ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());
|
||||
|
@ -237,12 +224,8 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
|
|||
protected Shape parseShape(String str) {
|
||||
if (str.length() == 0)
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "empty string shape");
|
||||
//In Solr trunk we only support "lat, lon" (or x y) as an additional format; in v4.0 we do the
|
||||
// weird Circle & Rect formats too (Spatial4j LegacyShapeReadWriterFormat).
|
||||
if (Character.isLetter(str.charAt(0))) {//WKT starts with a letter
|
||||
try {
|
||||
Shape shape = LegacyShapeReadWriterFormat.readShapeOrNull(str, ctx);
|
||||
if (shape != null)
|
||||
return shape;
|
||||
return ctx.readShapeFromWkt(str);
|
||||
} catch (Exception e) {
|
||||
String message = e.getMessage();
|
||||
|
@ -250,6 +233,9 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extend
|
|||
message = "Couldn't parse shape '" + str + "' because: " + message;
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, message, e);
|
||||
}
|
||||
} else {
|
||||
return SpatialUtils.parsePointSolrException(str, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -47,9 +47,6 @@
|
|||
<fieldType name="pointvector" class="solr.SpatialPointVectorFieldType"
|
||||
numberType="tdouble" distanceUnits="degrees"/>
|
||||
|
||||
<fieldType name="stqpt_u_oldworldbounds" class="solr.SpatialTermQueryPrefixTreeFieldType"
|
||||
geo="false" distCalculator="cartesian^2" worldBounds="0 0 1000 1000" distanceUnits="degrees"/>
|
||||
|
||||
<fieldType name="bbox" class="solr.BBoxField"
|
||||
numberType="tdoubleDV" distanceUnits="degrees"/>
|
||||
</types>
|
||||
|
|
|
@ -26,11 +26,8 @@ import com.spatial4j.core.context.SpatialContext;
|
|||
import com.spatial4j.core.distance.DistanceUtils;
|
||||
import com.spatial4j.core.shape.Point;
|
||||
import com.spatial4j.core.shape.Rectangle;
|
||||
import com.spatial4j.core.shape.impl.RectangleImpl;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.schema.AbstractSpatialFieldType;
|
||||
import org.apache.solr.schema.IndexSchema;
|
||||
import org.apache.solr.util.SpatialUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -72,13 +69,13 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
|
|||
public void testBadShapeParse400() {
|
||||
assertQEx(null, req(
|
||||
"fl", "id," + fieldName, "q", "*:*", "rows", "1000",
|
||||
"fq", "{!field f="+fieldName+"}Intersects(NonexistentShape(89.9,-130 d=9))"), 400);
|
||||
"fq", "{!field f=" + fieldName + "}Intersects(NonexistentShape(89.9,-130 d=9))"), 400);
|
||||
assertQEx(null, req(
|
||||
"fl", "id," + fieldName, "q", "*:*", "rows", "1000",
|
||||
"fq", "{!field f="+fieldName+"}Intersects(NonexistentShape(89.9,-130 d=9"), 400);//missing parens
|
||||
"fq", "{!field f=" + fieldName + "}Intersects(NonexistentShape(89.9,-130 d=9"), 400);//missing parens
|
||||
assertQEx(null, req(
|
||||
"fl", "id," + fieldName, "q", "*:*", "rows", "1000",
|
||||
"fq", "{!field f="+fieldName+"}Intersectssss"), 400);
|
||||
"fq", "{!field f=" + fieldName + "}Intersectssss"), 400);
|
||||
|
||||
ignoreException("NonexistentShape");
|
||||
try {
|
||||
|
@ -159,7 +156,7 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
|
|||
|
||||
assertQ(req(
|
||||
"fl", "id," + fieldName, "q", "*:*", "rows", "1000",
|
||||
"fq", "{!bbox sfield="+fieldName+" pt="+IN+" d=9}"),
|
||||
"fq", "{!bbox sfield=" + fieldName + " pt=" + IN + " d=9}"),
|
||||
"//result/doc/*[@name='" + fieldName + "']//text()='" + OUT + "'");
|
||||
}
|
||||
|
||||
|
@ -361,37 +358,6 @@ public class TestSolr4Spatial extends SolrTestCaseJ4 {
|
|||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void solr4OldShapeSyntax() throws Exception {
|
||||
assumeFalse("Mostly just valid for prefix-tree", fieldName.equals("pointvector"));
|
||||
|
||||
//we also test that the old syntax is parsed in worldBounds in the schema
|
||||
{
|
||||
IndexSchema schema = h.getCore().getLatestSchema();
|
||||
AbstractSpatialFieldType type = (AbstractSpatialFieldType) schema.getFieldTypeByName("stqpt_u_oldworldbounds");
|
||||
SpatialContext ctx = type.getStrategy("foo").getSpatialContext();
|
||||
assertEquals(new RectangleImpl(0, 1000, 0, 1000, ctx), ctx.getWorldBounds());
|
||||
}
|
||||
|
||||
//syntax supported in Solr 4 but not beyond
|
||||
// See Spatial4j LegacyShapeReadWriterFormat
|
||||
String rect = "-74.093 41.042 -69.347 44.558";//minX minY maxX maxY
|
||||
String circ = "Circle(4.56,1.23 d=0.0710)";
|
||||
|
||||
//show we can index this (without an error)
|
||||
assertU(adoc("id", "rect", fieldName, rect));
|
||||
if (!fieldName.equals("bbox")) {
|
||||
assertU(adoc("id", "circ", fieldName, circ));
|
||||
assertU(commit());
|
||||
}
|
||||
|
||||
//only testing no error
|
||||
assertJQ(req("q", "{!field f=" + fieldName + "}Intersects(" + rect + ")"));
|
||||
if (!fieldName.equals("bbox")) {
|
||||
assertJQ(req("q", "{!field f=" + fieldName + "}Intersects(" + circ + ")"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBadScoreParam() throws Exception {
|
||||
assertQEx("expect friendly error message",
|
||||
|
|
Loading…
Reference in New Issue