Skip to content

Search returning incorrect results after migration to latest version #85

@robintw

Description

@robintw

I had an old version of pgstac running, which I have just upgraded to the latest version. Since then, I've found that some of the search queries I've run have returned incorrect results. I actually found the incorrect results when querying using stac_fastapi, but I've checked by running queries using the underlying pgstac SQL functions and have found that they are returning incorrect results, which are then just displayed by stac_fastapi).

For example, when running the query:

SELECT * FROM pgstac.search('{"collection":"test-bec-4"}'::jsonb)

I get a JSON result which starts like this:

{
  "next": "N51E000.tif",
  "prev": null,
  "type": "FeatureCollection",
  "context": {
    "limit": 10,
    "returned": 10
  },
  "features": [
    {
      "id": "core-4",
      "bbox": [
        35,
        19.3,
        35,
        19.3
      ],
      "type": "Feature",
      "links": [
        {
          "rel": "self",
          "href": "http://localhost/test.tif",
          "type": "application/json"
        }
      ],
      "assets": {},
      "geometry": {
        "type": "Point",
        "coordinates": [
          35,
          19.3
        ]
      },
      "collection": "test-anglo-cores-3",
      "properties": {
        "datetime": "2020-02-08T11:23:00Z",
        "core-type": "shallow",
        "last-reviewed": "2021-03-19"
      },
...

In that returned JSON, it lists the collection as test-anglo-cores-3 not test-bec-4.

Running

SELECT * FROM items WHERE collection_id = 'test-bec-4'

gives me 100 results, which is the correct number - and shows that there are items in the database with that collection ID. I've also checked the content field of the items table, and in there the collection is also specified correctly as test-bec-4.

I have no idea how to go forward with debugging this, as my SQL skills are quite limited. Any help would be very much appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions