There are 2 issues with the current (temporary) manner in which the Content-Range header is set for requests that utilize the search function.
-
First support needs to be added for the Prefer header value count=exact which will return the total count of records returned by the dynamic SELECT statement when that request header is present. I'm unsure of the most optimal way to accomplish this (a Count(*) Over() window function or some other approach).
-
Second, the range prefix 0-10/* should account for the number of records returned by the current LIMIT OFFSET value so that it returns the correct value when there are less records than the LIMIT in the current page.
Both these are natively supported on PostgREST view endpoints (i.e items) but need to be included in the search function logic directly.
There are 2 issues with the current (temporary) manner in which the
Content-Rangeheader is set for requests that utilize the search function.First support needs to be added for the
Preferheader valuecount=exactwhich will return the total count of records returned by the dynamicSELECTstatement when that request header is present. I'm unsure of the most optimal way to accomplish this (aCount(*) Over()window function or some other approach).Second, the range prefix
0-10/*should account for the number of records returned by the currentLIMITOFFSETvalue so that it returns the correct value when there are less records than theLIMITin the current page.Both these are natively supported on PostgREST view endpoints (i.e
items) but need to be included in thesearchfunction logic directly.