pygeoapi icon indicating copy to clipboard operation
pygeoapi copied to clipboard

Add case-insensitive partial matching for text columns to Postgres provider

Open volcan01010 opened this issue 4 years ago • 0 comments

Summary

This pull request adds case-insensitive, partial matches for text columns to the Postgres provider. This makes it easier for users to search the API where the case and exact text are not known.

Description

We found situations where building a webpage on top of pygeoapi that it was convenient to be able to have case-insensitive searches to make it easier for users to find items, for example if entries in the database are all upper case. Including a wildcard in the search also make it easier to run queries where the exact values were not known.

This pull request adds these to the PostgreSQL provider.

Discussion

We are posting this pull request for consideration. It has made things more convenient for us, however it there are some other implications in terms of adding to the main Postgres provider.

  • At the moment, if a user doesn't know the exact search term, they can make a request to the single column to get all the items and find their item in there. This two-step process is extra work but not the end of the world
  • Hopefully the PostgreSQL provider will get CQL support in future, which will supersede this
  • There may be situations where the wildcard search will return items that were not desired

To test

The merge request includes changes to the included pygeoapi-config to add settings for the test Postgres instance. Uncommenting those lines will add it to the server.

It is then possible to test the following queries, all of which should return the same results:

  • [ ] http://localhost:5000/collections/hot_osm_waterways/items?f=json&lang=en-US&limit=10&skipGeometry=true&waterway=stream
  • [ ] http://localhost:5000/collections/hot_osm_waterways/items?f=json&lang=en-US&limit=10&skipGeometry=true&waterway=STREAM
  • [ ] http://localhost:5000/collections/hot_osm_waterways/items?f=json&lang=en-US&limit=10&skipGeometry=true&waterway=stre

volcan01010 avatar Dec 10 '21 12:12 volcan01010