org.apache.lucene.spatial.serialized
Class SerializedDVStrategy

java.lang.Object
  extended by org.apache.lucene.spatial.SpatialStrategy
      extended by org.apache.lucene.spatial.serialized.SerializedDVStrategy

public class SerializedDVStrategy
extends SpatialStrategy

A SpatialStrategy based on serializing a Shape stored into BinaryDocValues. This is not at all fast; it's designed to be used in conjuction with another index based SpatialStrategy that is approximated (like RecursivePrefixTreeStrategy) to add precision or eventually make more specific / advanced calculations on the per-document geometry. The serialization uses Spatial4j's BinaryCodec.

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
 
Fields inherited from class org.apache.lucene.spatial.SpatialStrategy
ctx
 
Constructor Summary
SerializedDVStrategy(com.spatial4j.core.context.SpatialContext ctx, String fieldName)
          Constructs the spatial strategy with its mandatory arguments.
 
Method Summary
 Field[] createIndexableFields(com.spatial4j.core.shape.Shape shape)
          Returns the IndexableField(s) from the shape that are to be added to the Document.
 ValueSource makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint, double multiplier)
          Make a ValueSource returning the distance between the center of the indexed shape and queryPoint.
 Filter makeFilter(SpatialArgs args)
          Returns a Filter that should be used with FilteredQuery.QUERY_FIRST_FILTER_STRATEGY.
 Query makeQuery(SpatialArgs args)
          Make a Query based principally on SpatialOperation and Shape from the supplied args.
 ValueSource makeShapeValueSource()
          Provides access to each shape per document as a ValueSource in which FunctionValues.objectVal(int) returns a Shape.
 
Methods inherited from class org.apache.lucene.spatial.SpatialStrategy
getFieldName, getSpatialContext, makeDistanceValueSource, makeRecipDistanceValueSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SerializedDVStrategy

public SerializedDVStrategy(com.spatial4j.core.context.SpatialContext ctx,
                            String fieldName)
Constructs the spatial strategy with its mandatory arguments.

Method Detail

createIndexableFields

public Field[] createIndexableFields(com.spatial4j.core.shape.Shape shape)
Description copied from class: SpatialStrategy
Returns the IndexableField(s) from the shape that are to be added to the 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:

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.

Specified by:
createIndexableFields in class SpatialStrategy
Returns:
Not null nor will it have null elements.

makeDistanceValueSource

public ValueSource makeDistanceValueSource(com.spatial4j.core.shape.Point queryPoint,
                                           double multiplier)
Description copied from class: SpatialStrategy
Make a ValueSource returning the distance between the center of the indexed shape and queryPoint. If there are multiple indexed shapes then the closest one is chosen. The result is multiplied by multiplier, which conveniently is used to get the desired units.

Specified by:
makeDistanceValueSource in class SpatialStrategy

makeQuery

public Query makeQuery(SpatialArgs args)
Description copied from class: SpatialStrategy
Make a Query based principally on SpatialOperation and Shape from the supplied args. The default implementation is
return new ConstantScoreQuery(makeFilter(args));

Overrides:
makeQuery in class SpatialStrategy

makeFilter

public Filter makeFilter(SpatialArgs args)
Returns a Filter that should be used with FilteredQuery.QUERY_FIRST_FILTER_STRATEGY. Use in another manner is likely to result in an UnsupportedOperationException to prevent misuse because the filter can't efficiently work via iteration.

Specified by:
makeFilter in class SpatialStrategy

makeShapeValueSource

public ValueSource makeShapeValueSource()
Provides access to each shape per document as a ValueSource in which FunctionValues.objectVal(int) returns a Shape.



Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.