Skip to content

Apache Lucene open-source search software

LUCENE-4188 inlined/removed SpatialStrategy.createStoredField()

David Wayne Smiley04bc7ee821f2
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java b/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java
index b1cf5e50c7d..9545a0fff6c 100644
--- a/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java
+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java
@@ -19,7 +19,6 @@ package org.apache.lucene.spatial;
import com.spatial4j.core.context.SpatialContext;
import com.spatial4j.core.shape.Shape;
-import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
@@ -96,16 +95,6 @@ public abstract class SpatialStrategy {
return new IndexableField[]{createField(shape)};
}
- /**
- * A convenience method for storing the shape in Lucene for retrieval in search results.
- * After calling this, add it to the document: {@link org.apache.lucene.document.Document#add(org.apache.lucene.index.IndexableField)}.
- * All this does is:
- * <pre>return new StoredField(getFieldName(),ctx.toString(shape));</pre>
- */
- public StoredField createStoredField(Shape shape) {
- return new StoredField(getFieldName(), ctx.toString(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/test/org/apache/lucene/spatial/PortedSolr3Test.java b/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
index dc11534095d..9ffbcb5657b 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
@@ -25,6 +25,7 @@ import com.spatial4j.core.shape.Point;
import com.spatial4j.core.shape.Shape;
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.search.FilteredQuery;
@@ -197,7 +198,7 @@ public class PortedSolr3Test extends StrategyTestCase {
doc.add(f);
}
if (storeShape)
- doc.add(strategy.createStoredField(shape));
+ doc.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));
return doc;
}
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
index e71e5d97231..4226dd55c72 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
@@ -24,6 +24,7 @@ import com.spatial4j.core.io.sample.SampleDataReader;
import com.spatial4j.core.shape.Shape;
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.query.SpatialArgsParser;
@@ -90,7 +91,7 @@ public abstract class StrategyTestCase extends SpatialTestCase {
}
}
if (storeShape)
- document.add(strategy.createStoredField(shape));
+ document.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));
documents.add(document);
}
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.java
index 636a42023d0..41e645ee5e3 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
@@ -26,6 +26,7 @@ import com.spatial4j.core.shape.simple.PointImpl;
import com.spatial4j.core.util.GeohashUtils;
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.SpatialMatchConcern;
@@ -157,7 +158,7 @@ public class TestRecursivePrefixTreeStrategy extends StrategyTestCase {
doc.add(f);
}
if (storeShape)
- doc.add(strategy.createStoredField(shape));
+ doc.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));
return doc;
}
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.java
index c2324052f99..51c0d0b74be 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
@@ -23,6 +23,7 @@ import com.spatial4j.core.shape.Shape;
import com.spatial4j.core.shape.simple.PointImpl;
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.spatial.SpatialTestCase;
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
@@ -45,7 +46,7 @@ public class TestTermQueryPrefixGridStrategy extends SpatialTestCase {
Document losAngeles = new Document();
losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));
losAngeles.add(prefixGridStrategy.createField(point));
- losAngeles.add(prefixGridStrategy.createStoredField(point));
+ losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), ctx.toString(point)));
addDocumentsAndCommit(Arrays.asList(losAngeles));