Hi,
I am using a version of GeoMesa from the
beginning of last week and I am mostly pleased with its
performance. I have, however, found a problem when I try to
query based upon feature ID.
I am able to successfully generate Filter
objects based upon feature IDs and use those filter objects to
modify and/or remove features within GeoMesa. I cannot,
however, use such feature ID filters to query GeoMesa without
getting a CQLException.
Here is some abbreviated example Java code
that illustrates the bug:
String id1 = "ID1";
FilterFactory2 ff =
CommonFactoryFinder.getFilterFactory2();
Filter filter =
ff.id(Collections.singleton(ff.featureId(id1)));
FeatureSource<SimpleFeatureType,
SimpleFeature> featureSource =
dataStore.getFeatureSource(featureName);
Query query = new Query(featureName,
filter);
FeatureCollection<SimpleFeatureType,
SimpleFeature> featureCollection =
featureSource.getFeatures(query);
FeatureIterator<SimpleFeature>
featureIterator = featureCollection.features(); // throws
CQLException
Here’s the exception that’s thrown:
org.geotools.filter.text.cql2.CQLException:
Encountered "IN ( ID1" at line 1, column 2.
Was expecting one of:
"not" ...
"include" ...
"exclude" ...
"(" ...
"[" ...
"id" ...
"in" ...
<IDENTIFIER> ...
<DATE> ...
<DATE_TIME> ...
"-" ...
<INTEGER_LITERAL> ...
<FLOATING_LITERAL> ...
<STRING_LITERAL> ...
"true" ...
"false" ...
"point" ...
"linestring" ...
"polygon" ...
"multipoint" ...
"multilinestring" ...
"multipolygon" ...
"geometrycollection" ...
"envelope" ...
"in" "(" <STRING_LITERAL> ...
"in" "(" <INTEGER_LITERAL> ...
Parsing : (IN (ID1)).
at
org.geotools.filter.text.ecql.ECQLCompiler.compileFilter(ECQLCompiler.java:102)
at
org.geotools.filter.text.commons.CompilerUtil.parseFilter(CompilerUtil.java:196)
at
org.geotools.filter.text.ecql.ECQL.toFilter(ECQL.java:120)
at
org.geotools.filter.text.ecql.ECQL.toFilter(ECQL.java:99)
at
geomesa.core.iterators.IteratorTrigger$.getFilterAttributes(IteratorTrigger.scala:114)
at
geomesa.core.iterators.IteratorTrigger$.passThroughFilter(IteratorTrigger.scala:109)
at
geomesa.core.iterators.IteratorTrigger$$anonfun$8.apply(IteratorTrigger.scala:70)
at
geomesa.core.iterators.IteratorTrigger$$anonfun$8.apply(IteratorTrigger.scala:70)
at
scala.Option.map(Option.scala:145)
at
geomesa.core.iterators.IteratorTrigger$.useIndexOnlyIterator(IteratorTrigger.scala:70)
at
geomesa.core.iterators.IteratorTrigger$.chooseIterator(IteratorTrigger.scala:52)
at
geomesa.core.index.IndexQueryPlanner.stIdxQuery(IndexQueryPlanner.scala:373)
at
geomesa.core.index.IndexQueryPlanner.runAttrIdxQuery(IndexQueryPlanner.scala:164)
at
geomesa.core.index.IndexQueryPlanner.geomesa$core$index$IndexQueryPlanner$$runQuery(IndexQueryPlanner.scala:135)
at
geomesa.core.index.IndexQueryPlanner$$anonfun$getIterator$1.apply(IndexQueryPlanner.scala:94)
at
geomesa.core.index.IndexQueryPlanner$$anonfun$getIterator$1.apply(IndexQueryPlanner.scala:94)
at
scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)
at
geomesa.core.util.CloseableIterator$$anon$3.hasNext(CloseableIterator.scala:20)
at
geomesa.core.iterators.DeDuplicatingIterator.findTop(DeDuplicatingIterator.scala:51)
at
geomesa.core.iterators.DeDuplicatingIterator.<init>(DeDuplicatingIterator.scala:58)
at
geomesa.core.index.IndexSchema.adaptIterator(IndexSchema.scala:117)
at
geomesa.core.index.IndexSchema.query(IndexSchema.scala:102)
at
geomesa.core.data.AccumuloFeatureReader.<init>(AccumuloFeatureReader.scala:32)
at
geomesa.core.data.AccumuloDataStore.getFeatureReader(AccumuloDataStore.scala:751)
at
geomesa.core.data.AccumuloDataStore.getFeatureReader(AccumuloDataStore.scala:60)
at
org.geotools.data.AbstractDataStore.getFeatureReader(AbstractDataStore.java:369)
at
org.geotools.data.DefaultFeatureResults.reader(DefaultFeatureResults.java:215)
at
org.geotools.data.store.DataFeatureCollection.openIterator(DataFeatureCollection.java:231)
at
org.geotools.data.store.DataFeatureCollection.iterator(DataFeatureCollection.java:199)
at
org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:188)
at
org.geotools.data.store.DataFeatureCollection.features(DataFeatureCollection.java:79)
Is there a safe way to query based on
feature ID? Has this bug already been fixed?
Thanks,
Beau