I am querying a layer in ArcGIS map with ArcGIS Maps SDK for JavaScript. When I query a feature with geometry and without type a where clause into the query, the query does not return results.
If I query a feature with geometry and with typing a where clause which reduces the result set of the query, it works like expected, it selects correct features from layer.
If I query a feature with geometry and with typing a where clause which does not reduce the result set of the query(for ex where 1=1 condition), it does not work, does not select any featureset.
here is my code:
const query = new Query();
query.geometry = geometry;
query.returnGeometry = true;
query.units = 'meters';
query.spatialRelationship = (geometry.type === 'point') ? 'intersects' : 'contains';
query.outFields = ['*'];
// query.where = "name like '%'"; -> not working
// query.where = "name like 'L%'"; -> works as expected(note that all elements in the layer already starts with letter 'L')
// query.where = "ESRI_OID > 0"; -> works for some
// query.where = "1=1"; -> not working
layer.queryFeatures(query).then(featureSet => {
// see the results
});
Why my query is not working if I do not add a where clause which reduces the resultset?
1 Answer 1
We realized that, if the geographical spatial reference is null in the database for even only one record, whole querying mechanism is corrupting. We analyzed all data and found a corrupted record with spatial reference null. After we fixed that, all the things became normal.
query.where = "state_name like '%'"
andquery.where = "1=1"
on feature layerurl: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/OverlaySchools/FeatureServer/0"
.