Example usage for org.apache.lucene.spatial.vector PointVectorStrategy SUFFIX_X

List of usage examples for org.apache.lucene.spatial.vector PointVectorStrategy SUFFIX_X

Introduction

In this page you can find the example usage for org.apache.lucene.spatial.vector PointVectorStrategy SUFFIX_X.

Prototype

String SUFFIX_X

To view the source code for org.apache.lucene.spatial.vector PointVectorStrategy SUFFIX_X.

Click Source Link

Usage

From source file:org.apache.blur.analysis.type.spatial.SpatialPointVectorStrategyFieldTypeDefinition.java

License:Apache License

@Override
public void configure(String fieldNameForThisInstance, Map<String, String> properties,
        Configuration configuration) {
    _ctx = SpatialContext.GEO;/*from w  ww  .j  a  v a 2 s.  c  o  m*/
    _strategy = new PointVectorStrategy(_ctx, fieldNameForThisInstance);
    _shapeReadWriter = new ShapeReadWriter<SpatialContext>(_ctx);
    _alternateFieldNames = Arrays.asList(fieldNameForThisInstance + PointVectorStrategy.SUFFIX_X,
            fieldNameForThisInstance + PointVectorStrategy.SUFFIX_Y);
    addSupportedIndexedShapes(Point.class);
    addSupportedOperations(SpatialOperation.Intersects);
}

From source file:org.apache.solr.schema.SpatialPointVectorFieldType.java

License:Apache License

/**
 * Adds X and Y fields to the given schema for each field with this class as its field type.
 * /* ww w  .  ja  v  a2  s .  c  om*/
 * {@inheritDoc}
 * 
 * @param schema {@inheritDoc}
 *
 */
@Override
public void inform(IndexSchema schema) {
    FieldType fieldType = schema.getFieldTypeByName(numberFieldName);
    if (fieldType == null) {
        throw new RuntimeException("Can not find number field: " + numberFieldName);
    }
    //TODO support other numeric types in the future
    if (!(fieldType instanceof TrieDoubleField)) {
        throw new RuntimeException("field type must be TrieDoubleField: " + fieldType);
    }
    precisionStep = ((TrieField) fieldType).getPrecisionStep();

    //Just set these, delegate everything else to the field type
    final int p = (INDEXED | TOKENIZED | OMIT_NORMS | OMIT_TF_POSITIONS);
    List<SchemaField> newFields = new ArrayList<SchemaField>();
    for (SchemaField sf : schema.getFields().values()) {
        if (sf.getType() == this) {
            String name = sf.getName();
            newFields.add(new SchemaField(name + PointVectorStrategy.SUFFIX_X, fieldType, p, null));
            newFields.add(new SchemaField(name + PointVectorStrategy.SUFFIX_Y, fieldType, p, null));
        }
    }
    for (SchemaField newField : newFields) {
        schema.getFields().put(newField.getName(), newField);
    }
}