GeoServer WFS – Persistent FID Issue

geoserverqgiswfs

My organisation uses a SAAS and part of that service publishes data via a WFS using Geoserver 2.7.0. I have sent a GetFeature request via a browser (IE11) and it returns the GML however, if I refresh the link the FID changes:

:wfs_BBQ gml:id="wfs_BBQ.fid-74424e53_159f7837ba8_350">

:wfs_BBQ gml:id="wfs_BBQ.fid-74424e53_159f7837ba8_ec3">

I am using QGIS 2.18.3 (running on Win 10) and I'm told QGIS needs persistent FIDs (see: Duplicate WFS Featues in QGIS 2.18.3) and that Geoserver should create a persistent FID if the WFS has a Primary Key. The data does have a Unique ID (integer) so I'm hoping this meets the requirement.

How do I ensure the FIDs are persistent?

Best Answer

To generate a permanent FID GeoTools (which underlies GeoServer) uses whatever the underlying datastore provides. So if you are querying a database should be the primary key. So if your FIDs change the problem is likely that you haven't set a primary key up for your table, or GeoTools can't work out what it is. This may occur if you are using a view, to fix this you can create a metadata table to help out.

You would also see this effect if you were foolish enough to try to run a WFS on top of a Shapefile, here the solution is not to do that.

Related Question