It works for me -
if I ask for resulttype=hits
:
http://localhost:8080/geoserver/wfs?service=WFS&version=2.0.0&request=GetFeature&typenames=sf:bugsites&filter=%3Cfes:Filter%20xmlns:fes=%22http://www.opengis.net/fes/2.0%22%3E%3Cfes:ResourceId%20rid=%22bugsites.3%22/%3E%3C/fes:Filter%3E&RESULTTYPE=hits
I get the following response:
<?xml version="1.0" encoding="UTF-8"?><wfs:FeatureCollection xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" next="http://localhost:8080/geoserver/wfs?FILTER=%3Cfes%3AFilter%20xmlns%3Afes%3D%22http%3A%2F%2Fwww.opengis.net%2Ffes%2F2.0%22%3E%3Cfes%3AResourceId%20rid%3D%22bugsites.3%22%2F%3E%3C%2Ffes%3AFilter%3E&REQUEST=GetFeature&RESULTTYPE=results&VERSION=2.0.0&TYPENAMES=sf%3Abugsites&SERVICE=WFS&STARTINDEX=0" numberMatched="1" numberReturned="0" timeStamp="2019-07-17T16:26:26.106Z" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd"/>
which has the attribute numberMatched="1"
as expected.
Update
Though oddly I get exactly the same result with &outputFormat=application%2Fjson
which is odd and possibly a bug, but I would need to read the WFS spec more closely to be sure.
Further Update
Seems I've seen this before 3 years ago but no one cares enough to fix it or fund a fix.