Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does pg_featureserv support JSONB fields? #155

Open
donnyv opened this issue Jan 16, 2024 · 4 comments
Open

Does pg_featureserv support JSONB fields? #155

donnyv opened this issue Jan 16, 2024 · 4 comments
Labels
question Further information is requested

Comments

@donnyv
Copy link

donnyv commented Jan 16, 2024

I have a spatial table with a table id, geometry field, unique id field and a JSONB field for the rest of the data. Does pg_featureserv expand JSONB fields or would I have to create a View to do that?

@dr-jts
Copy link
Collaborator

dr-jts commented Mar 4, 2024

As far as I know pg_featureserv doesn't expand JSONB.

@dr-jts dr-jts added the question Further information is requested label Mar 4, 2024
@jamesscottbrown
Copy link

jamesscottbrown commented Mar 7, 2024

Edit: my initial response was probably not directly helpful, as the question was about pg_tileserv rather than pg_featureserv.

MVT tiles

pg_tileserv constructs a SQL query that creates a tile using the ST_AsMVT comamnd in PostGIS. The PostGIS docs say:

The Mapbox Vector Tile format can store features with varying sets of attributes. To use this capability supply a JSONB column in the row data containing Json objects one level deep. The keys and values in the JSONB values will be encoded as feature attributes.

So with pg_tileserv, a JSONB field should be automatically expanded out to set multiple feature attributes.

GeoJSON

pg_featureserv uses the PostGIS function ST_AsGeoJSON, which acts differently: as JSON can represent nested data it doesn't do flattening. If you apply the function to data with a JSON column called data, the resulting features will have a property called data that has the same structure as the column (i.e., it will be an object). This is arguably more useful than automatically flattening data structures unnecessarily.

@donnyv
Copy link
Author

donnyv commented Mar 11, 2024

@jamesscottbrown So can I search JSONB fields or not using pg_featureserv?

@JakobMiksch
Copy link
Contributor

@donnyv does this PR #165 fix your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants