public class TestTermQueryPrefixGridStrategy extends SpatialTestCase {
@Test
public void testNGramPrefixGridLosAngeles() throws IOException {
SpatialContext ctx = SpatialContext.GEO;
TermQueryPrefixTreeStrategy prefixGridStrategy = new TermQueryPrefixTreeStrategy(new QuadPrefixTree(ctx), "geo");
Shape point = ctx.makePoint(-118.243680, 34.052230);
Document losAngeles = new Document();
losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));
for (IndexableField field : prefixGridStrategy.createIndexableFields(point)) {
losAngeles.add(field);
}
losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), ctx.toString(point)));
addDocumentsAndCommit(Arrays.asList(losAngeles));
// This won't work with simple spatial context...
SpatialArgsParser spatialArgsParser = new SpatialArgsParser();