I´m using Geoserver to query features through WFS in an Web Application with Openlayers as client. The queried layer is using SQL Server as backend storage.
When applying a spatial index to the queried layer in SQL Server, the response of an identify is very inaccurate and lots of features that are not even nearby the identify click are returned. When removing the spatial index in the backend, the identify in the client is accurate and only the clicked feature is returned.
The issue is that Geoserver uses the "Filter()" method of SQL Server when querying the bounds calculated by Openlayers for the area to identify. The "Filter()" method is using the spatial index to determine what features has to be returned. The documentation (http://msdn.microsoft.com/en-us/library/cc645883%28v=sql.105%29.aspx) states, that the "Filter" method is fast, but inaccurate when a spatial index is applied and potentially returns features outside the queried bounds.
Is there a possibilty to maintain a spatial index in the SQL Server table (is necessary for other functions operating on the table) and using STIntersects() instead of "Filter()" to filter the queried features when running an identify through WFS on Geoserver and get accurate results ?
Geoserver is version 2.5.1 and SQL Server is 2008 R2.