1

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?

Hornbydd
44.9k5 gold badges43 silver badges84 bronze badges
asked Apr 22, 2024 at 8:00
5
  • What do you mean by reducing my question to one question? I have one question about why my query is not working when I do not add a where clause to it. There is no multiple questions as you see. And also dhanged my one question that is more understandable for everyone. Commented Apr 22, 2024 at 12:18
  • "When I query a feature with geometry and without type a where clause into the query, the query does not return results". 'When' in here is not a question phrase, it means 'if' in here. But if it is confusing for you I will change to 'if' phrase. Commented Apr 24, 2024 at 7:32
  • For me it works without problems with query.where = "state_name like '%'" and query.where = "1=1" on feature layer url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/OverlaySchools/FeatureServer/0". Commented Apr 27, 2024 at 20:35
  • We realize 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. Commented May 16, 2024 at 9:07
  • 1
    You can put that info into answer, it might help somebody with the same problem. Commented May 16, 2024 at 9:20

1 Answer 1

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.

answered May 16, 2024 at 9:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.