Index: lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (revision 1360316) +++ lucene/spatial/src/java/org/apache/lucene/spatial/prefix/PrefixTreeStrategy.java (revision ) @@ -62,7 +62,7 @@ } @Override - public IndexableField createField(Shape shape) { + public IndexableField[] createIndexableFields(Shape shape) { int detailLevel = grid.getMaxLevelForPrecision(shape,distErrPct); List 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 @@ //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. */ Index: lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java (revision 1360316) +++ lucene/spatial/src/java/org/apache/lucene/spatial/SpatialStrategy.java (revision ) @@ -59,11 +59,6 @@ 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 @@ } /** - * 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 shape 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. *

- * Note: If you want to store the shape as a string for retrieval in search - * results, you could add it like this: + * Note: If you want to store the shape as a string for retrieval in + * search results, you could add it like this: *

document.add(new StoredField(fieldName,ctx.toString(shape)));
- * 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. Index: lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java (revision 1360316) +++ lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java (revision ) @@ -194,7 +194,7 @@ 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) Index: lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (revision 1360316) +++ lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (revision ) @@ -85,10 +85,8 @@ 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 + for (IndexableField f : strategy.createIndexableFields(shape)) { - document.add(f); + document.add(f); - } } if (storeShape) document.add(new StoredField(strategy.getFieldName(), ctx.toString(shape))); Index: lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java (revision 1360316) +++ lucene/spatial/src/java/org/apache/lucene/spatial/vector/TwoDoublesStrategy.java (revision ) @@ -77,12 +77,7 @@ } @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); @@ -96,11 +91,6 @@ throw new IllegalArgumentException( "TwoDoublesStrategy can not index: "+shape ); } return new IndexableField[0]; // nothing (solr does not support null) - } - - @Override - public IndexableField createField(Shape shape) { - throw new UnsupportedOperationException("Point is poly field"); } @Override Index: lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java (revision 1360316) +++ lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java (revision ) @@ -25,6 +25,7 @@ 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 @@ 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)); Index: lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java (revision 1360316) +++ lucene/spatial/src/java/org/apache/lucene/spatial/bbox/BBoxStrategy.java (revision ) @@ -92,7 +92,7 @@ //--------------------------------- @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); @@ -103,16 +103,6 @@ fields[3] = new DoubleField(field_maxY, bbox.getMaxY(), doubleFieldType); fields[4] = new Field( field_xdl, bbox.getCrossesDateLine()?"T":"F", StringField.TYPE_NOT_STORED); return fields; - } - - @Override - public IndexableField createField(Shape shape) { - throw new UnsupportedOperationException("BBOX is poly field"); - } - - @Override - public boolean isPolyField() { - return true; } //--------------------------------- Index: lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java (revision 1360316) +++ lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestRecursivePrefixTreeStrategy.java (revision ) @@ -154,7 +154,7 @@ 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)