LUCENE-4188 inlined/removed SpatialStrategy.createStoredField()

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1360028 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2012-07-11 06:28:39 +00:00
parent 401bfde9bd
commit 04bc7ee821
5 changed files with 8 additions and 15 deletions

View File

@ -19,7 +19,6 @@ package org.apache.lucene.spatial;
import com.spatial4j.core.context.SpatialContext; import com.spatial4j.core.context.SpatialContext;
import com.spatial4j.core.shape.Shape; import com.spatial4j.core.shape.Shape;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.queries.function.FunctionQuery; import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource; import org.apache.lucene.queries.function.ValueSource;
@ -96,16 +95,6 @@ public abstract class SpatialStrategy {
return new IndexableField[]{createField(shape)}; 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. * The value source yields a number that is proportional to the distance between the query shape and indexed data.
*/ */

View File

@ -25,6 +25,7 @@ import com.spatial4j.core.shape.Point;
import com.spatial4j.core.shape.Shape; import com.spatial4j.core.shape.Shape;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField; import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.FilteredQuery; import org.apache.lucene.search.FilteredQuery;
@ -197,7 +198,7 @@ public class PortedSolr3Test extends StrategyTestCase {
doc.add(f); doc.add(f);
} }
if (storeShape) if (storeShape)
doc.add(strategy.createStoredField(shape)); doc.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));
return doc; return doc;
} }

View File

@ -24,6 +24,7 @@ import com.spatial4j.core.io.sample.SampleDataReader;
import com.spatial4j.core.shape.Shape; import com.spatial4j.core.shape.Shape;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField; import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.spatial.query.SpatialArgsParser; import org.apache.lucene.spatial.query.SpatialArgsParser;
@ -90,7 +91,7 @@ public abstract class StrategyTestCase extends SpatialTestCase {
} }
} }
if (storeShape) if (storeShape)
document.add(strategy.createStoredField(shape)); document.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));
documents.add(document); documents.add(document);
} }

View File

@ -26,6 +26,7 @@ import com.spatial4j.core.shape.simple.PointImpl;
import com.spatial4j.core.util.GeohashUtils; import com.spatial4j.core.util.GeohashUtils;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField; import org.apache.lucene.document.StringField;
import org.apache.lucene.index.IndexableField; import org.apache.lucene.index.IndexableField;
import org.apache.lucene.spatial.SpatialMatchConcern; import org.apache.lucene.spatial.SpatialMatchConcern;
@ -157,7 +158,7 @@ public class TestRecursivePrefixTreeStrategy extends StrategyTestCase {
doc.add(f); doc.add(f);
} }
if (storeShape) if (storeShape)
doc.add(strategy.createStoredField(shape)); doc.add(new StoredField(strategy.getFieldName(), ctx.toString(shape)));
return doc; return doc;
} }

View File

@ -23,6 +23,7 @@ import com.spatial4j.core.shape.Shape;
import com.spatial4j.core.shape.simple.PointImpl; import com.spatial4j.core.shape.simple.PointImpl;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field; import org.apache.lucene.document.Field;
import org.apache.lucene.document.StoredField;
import org.apache.lucene.document.StringField; import org.apache.lucene.document.StringField;
import org.apache.lucene.spatial.SpatialTestCase; import org.apache.lucene.spatial.SpatialTestCase;
import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree; import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
@ -45,7 +46,7 @@ public class TestTermQueryPrefixGridStrategy extends SpatialTestCase {
Document losAngeles = new Document(); Document losAngeles = new Document();
losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES)); losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));
losAngeles.add(prefixGridStrategy.createField(point)); losAngeles.add(prefixGridStrategy.createField(point));
losAngeles.add(prefixGridStrategy.createStoredField(point)); losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), ctx.toString(point)));
addDocumentsAndCommit(Arrays.asList(losAngeles)); addDocumentsAndCommit(Arrays.asList(losAngeles));