Apache Lucene open-source search software
LUCENE-4192 remove spatial isPolyField and createField
David Wayne Smileye43973683e67
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java b/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.javaindex 9545a0fff6c..a04a5805861 100644--- a/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java@@ -59,11 +59,6 @@ public abstract class SpatialStrategy {return ctx;}- /** Corresponds with Solr's FieldType.isPolyField(). */- public boolean isPolyField() {- return false;- }-/*** The name of the field or the prefix of them if there are multiple* fields needed internally.@@ -74,26 +69,19 @@ public abstract class SpatialStrategy {}/**- * Corresponds with Solr's FieldType.createField().- *- * This may return a null field if it does not want to make anything.- * This is reasonable behavior if 'ignoreIncompatibleGeometry=true' and the- * geometry is incompatible- */- public abstract IndexableField createField(Shape shape);-- /**- * Corresponds with Solr's FieldType.createFields().+ * Returns the IndexableField(s) from the <code>shape</code> that are to be+ * added to the {@link org.apache.lucene.document.Document}. These fields+ * are expected to be marked as indexed and not stored.* <p/>- * Note: If you want to <i>store</i> the shape as a string for retrieval in search- * results, you could add it like this:+ * Note: If you want to <i>store</i> the shape as a string for retrieval in+ * search results, you could add it like this:* <pre>document.add(new StoredField(fieldName,ctx.toString(shape)));</pre>- * The particular string representation used doesn't matter to the Strategy since it- * doesn't use it.+ * The particular string representation used doesn't matter to the Strategy+ * since it doesn't use it.+ *+ * @return Not null nor will it have null elements.*/- public IndexableField[] createFields(Shape shape) {- return new IndexableField[]{createField(shape)};- }+ public abstract IndexableField[] createIndexableFields(Shape shape);/*** The value source yields a number that is proportional to the distance between the query shape and indexed data.diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java b/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.javaindex 226a8660568..5c74d197765 100644--- a/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java@@ -92,7 +92,7 @@ public class BBoxStrategy extends SpatialStrategy {//---------------------------------@Override- public IndexableField[] createFields(Shape shape) {+ public IndexableField[] createIndexableFields(Shape shape) {Rectangle bbox = shape.getBoundingBox();FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);doubleFieldType.setNumericPrecisionStep(precisionStep);@@ -105,16 +105,6 @@ public class BBoxStrategy extends SpatialStrategy {return fields;}- @Override- public IndexableField createField(Shape shape) {- throw new UnsupportedOperationException("BBOX is poly field");- }-- @Override- public boolean isPolyField() {- return true;- }-//---------------------------------// Query Builder//---------------------------------diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java b/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.javaindex ed2b3172f0a..cac0862ea03 100644--- a/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java@@ -62,7 +62,7 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {}@Override- public IndexableField createField(Shape shape) {+ public IndexableField[] createIndexableFields(Shape shape) {int detailLevel = grid.getMaxLevelForPrecision(shape,distErrPct);List<Node> cells = grid.getNodes(shape, detailLevel, true);//true=intermediates cells//If shape isn't a point, add a full-resolution center-point so that@@ -77,7 +77,8 @@ public abstract class PrefixTreeStrategy extends SpatialStrategy {//TODO is CellTokenStream supposed to be re-used somehow? see Uwe's comments:// http://code.google.com/p/lucene-spatial-playground/issues/detail?id=4- return new Field(getFieldName(),new CellTokenStream(cells.iterator()), FIELD_TYPE);+ Field field = new Field(getFieldName(), new CellTokenStream(cells.iterator()), FIELD_TYPE);+ return new IndexableField[]{field};}/* Indexed, tokenized, not stored. */diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java b/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.javaindex 37b6680e7fa..7f420d562f6 100644--- a/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java@@ -77,12 +77,7 @@ public class TwoDoublesStrategy extends SpatialStrategy {}@Override- public boolean isPolyField() {- return true;- }-- @Override- public IndexableField[] createFields(Shape shape) {+ public IndexableField[] createIndexableFields(Shape shape) {if( shape instanceof Point ) {Point point = (Point)shape;FieldType doubleFieldType = new FieldType(DoubleField.TYPE_NOT_STORED);@@ -98,11 +93,6 @@ public class TwoDoublesStrategy extends SpatialStrategy {return new IndexableField[0]; // nothing (solr does not support null)}- @Override- public IndexableField createField(Shape shape) {- throw new UnsupportedOperationException("Point is poly field");- }-@Overridepublic ValueSource makeValueSource(SpatialArgs args) {Point p = args.getShape().getCenter();diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java b/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.javaindex 9ffbcb5657b..42d16850e16 100644--- a/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java@@ -194,7 +194,7 @@ public class PortedSolr3Test extends StrategyTestCase {private Document newDoc(String id, Shape shape) {Document doc = new Document();doc.add(new StringField("id", id, Field.Store.YES));- for (IndexableField f : strategy.createFields(shape)) {+ for (IndexableField f : strategy.createIndexableFields(shape)) {doc.add(f);}if (storeShape)diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.javaindex 4226dd55c72..1e30cbbf5d0 100644--- a/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java@@ -85,10 +85,8 @@ public abstract class StrategyTestCase extends SpatialTestCase {document.add(new StringField("id", data.id, Field.Store.YES));document.add(new StringField("name", data.name, Field.Store.YES));Shape shape = ctx.readShape(data.shape);- for (IndexableField f : strategy.createFields(shape)) {- if( f != null ) { // null if incompatibleGeometry && ignore- document.add(f);- }+ for (IndexableField f : strategy.createIndexableFields(shape)) {+ document.add(f);}if (storeShape)document.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java b/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.javaindex 41e645ee5e3..4131d7f58b0 100644--- a/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java@@ -154,7 +154,7 @@ public class TestRecursivePrefixTreeStrategy extends StrategyTestCase {private Document newDoc(String id, Shape shape) {Document doc = new Document();doc.add(new StringField("id", id, Field.Store.YES));- for (IndexableField f : strategy.createFields(shape)) {+ for (IndexableField f : strategy.createIndexableFields(shape)) {doc.add(f);}if (storeShape)diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java b/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.javaindex 51c0d0b74be..d63cf7ea608 100644--- a/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java@@ -25,6 +25,7 @@ import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;import org.apache.lucene.document.StoredField;import org.apache.lucene.document.StringField;+import org.apache.lucene.index.IndexableField;import org.apache.lucene.spatial.SpatialTestCase;import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;import org.apache.lucene.spatial.query.SpatialArgsParser;@@ -45,7 +46,9 @@ public class TestTermQueryPrefixGridStrategy extends SpatialTestCase {Document losAngeles = new Document();losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));- losAngeles.add(prefixGridStrategy.createField(point));+ for (IndexableField field : prefixGridStrategy.createIndexableFields(point)) {+ losAngeles.add(field);+ }losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), ctx.toString(point)));addDocumentsAndCommit(Arrays.asList(losAngeles));