I am trying to query a MapServer layer via URL, but I am having trouble finding syntax examples. I want to use the indexquery mode and found this documentation http://gislars.github.io/mapserver_docs/cgi/controls.html as well as this http://mapserver.org/tutorial/example1-1.html. I am successful in returning the layer in map mode, but am not sure how to structure the indexquery string.

UPDATE: Upon further investigation it seems I need to use itemnquery mode. I have found some syntax that seems like it should work in this thread https://github.com/mapserver/mapserver/issues/4711, but I don't have access to the column names, and am not sure how to get them. Ultimately I'd like to query all records. Is there a general query for selecting all records, or is there a way to query a layer to return field names?


The WFS service in the link you provided is not enabled but WMS is enabled, to enable the WFS add below line into your web section in map file: "wfs_enable_request" "*" so it should appear as follow:

    IMAGEPATH "/ms4w/tmp/ms_tmp/" 
    IMAGEURL "/ms_tmp/"
           "wms_enable_request" "*"
            "wfs_enable_request" "*"

Now to get the columns for layer parcels, use below link:


for detailed information about other WFS, check below link: http://docs.geoserver.org/latest/en/user/services/wfs/reference.html#describefeaturetype

  • Thanks for the reply. I don't believe I have access to or can make changes to the map file. But you say WMS is enabled? How would I structure the url to view the WMS and is it possible to query all features from the WMS? – kflaw Jul 11 '16 at 10:43
  • Your WMS is enabled as I can get the capabilities & can see the layers as below link: qpublic5.qpublic.net/cgi-bin/mapserv56?map=/qpub1/maps/ky/mason/… – Shiko Jul 11 '16 at 10:44
  • It does appear that another layer, qparcels, is queryable, but it only seems to return a feature number, when i load the WMS into a desktop GIS – kflaw Jul 11 '16 at 15:06
  • You can query feature using WMS based on coordinates (x & y) to get the map image but if you need to query an attribute and return data, then you need to enable WFS. check this link to get clear image regarding the WMS & WFS. – Shiko Jul 12 '16 at 7:55
  • I think I generally understand but got a little confused because I'm used to working with esri map services which can allow querying of features. And as I mentioned, it does look like one of the layers in this WMS, qparcels, allows queries. – kflaw Jul 12 '16 at 15:16

Per your updated question, to request a schema of the feature attributes you may use desribeFeatureType method.


Here is a similar Q/A:

How to get column names of layer (WMS) using OpenLayers?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.