Example usage for org.apache.lucene.spatial.prefix PrefixTreeStrategy isPointsOnly

List of usage examples for org.apache.lucene.spatial.prefix PrefixTreeStrategy isPointsOnly

Introduction

In this page you can find the example usage for org.apache.lucene.spatial.prefix PrefixTreeStrategy isPointsOnly.

Prototype

public boolean isPointsOnly() 

Source Link

Usage

From source file:org.elasticsearch.index.mapper.GeoShapeFieldMapperTests.java

License:Apache License

public void testQuadtreeConfiguration() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
            .startObject("location").field("type", "geo_shape").field("tree", "quadtree")
            .field("tree_levels", "6").field("distance_error_pct", "0.5").field("points_only", true).endObject()
            .endObject().endObject().endObject().string();

    DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1",
            new CompressedXContent(mapping));
    FieldMapper fieldMapper = defaultMapper.mappers().getMapper("location");
    assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));

    GeoShapeFieldMapper geoShapeFieldMapper = (GeoShapeFieldMapper) fieldMapper;
    PrefixTreeStrategy strategy = geoShapeFieldMapper.fieldType().defaultStrategy();

    assertThat(strategy.getDistErrPct(), equalTo(0.5));
    assertThat(strategy.getGrid(), instanceOf(QuadPrefixTree.class));
    assertThat(strategy.getGrid().getMaxLevels(), equalTo(6));
    assertThat(strategy.isPointsOnly(), equalTo(true));
}

From source file:org.elasticsearch.index.mapper.GeoShapeFieldMapperTests.java

License:Apache License

public void testPointsOnlyOption() throws IOException {
    String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
            .startObject("location").field("type", "geo_shape").field("tree", "geohash")
            .field("points_only", true).endObject().endObject().endObject().endObject().string();

    DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type1",
            new CompressedXContent(mapping));
    FieldMapper fieldMapper = defaultMapper.mappers().getMapper("location");
    assertThat(fieldMapper, instanceOf(GeoShapeFieldMapper.class));

    GeoShapeFieldMapper geoShapeFieldMapper = (GeoShapeFieldMapper) fieldMapper;
    PrefixTreeStrategy strategy = geoShapeFieldMapper.fieldType().defaultStrategy();

    assertThat(strategy.getGrid(), instanceOf(GeohashPrefixTree.class));
    assertThat(strategy.isPointsOnly(), equalTo(true));
}