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

Simple search returns items onlly with properties.datetime field #217

Open
iliion opened this issue Mar 22, 2024 · 12 comments
Open

Simple search returns items onlly with properties.datetime field #217

iliion opened this issue Mar 22, 2024 · 12 comments

Comments

@iliion
Copy link

iliion commented Mar 22, 2024

Simple search http://localhost:8000/search?limit=10 returns items onlly with properties.datetime field

In particular in line
https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/987f0b924b45e3f63302758b6e63d38ba504964f/stac_fastapi/core/stac_fastapi/core/core.py#L593C12-L593C64

filter_kwargs = search_request.fields.filter_fields

filter_fields is equal to

{'exclude': {}, 'include': {'assets': Ellipsis, 'bbox': Ellipsis, 'collection': Ellipsis, 'geometry': Ellipsis, 'id': Ellipsis, 'links': Ellipsis, 'properties': {'datetime'}, 'stac_version': Ellipsis, 'type': Ellipsis}}

As a response i get the FeatureCollection

{
  "type": "FeatureCollection",
  "features": [ {
    "type": "Feature",
    "properties": {
      "datetime": "2015-07-04T10:10:06.027000+00:00"
    },
    . . .
  ]
  . . .
}

Shouldnt the filter_kwargs` be equal to

{'exclude': {}, 'include': {'assets': Ellipsis, 'bbox': Ellipsis, 'collection': Ellipsis, 'geometry': Ellipsis, 'id': Ellipsis, 'links': Ellipsis, 'properties': Ellipsis, 'stac_version': Ellipsis, 'type': Ellipsis}}

FYI.
The item has the following properties

"properties": {
  "sat:relative_orbit": 22,
  "start_datetime": "2015-07-04T10:10:06.027Z",
  "end_datetime": "2015-07-04T10:10:06.027Z",
  "processing:facility": "EPA_",
  "title": "S2A_MSIL2A_20150704T101006_N0204_R022_T30NYK_20150704T102420.SAFE",
  "platform": "Sentinel-2A",
  "view:sun_elevation": 30.130819756471,
  "datetime": "2015-07-04T10:10:06.027Z",
  "instruments": [],
  "constellation": "sentinel-2",
  "sat:orbit_state": "descending",
  "eo:cloud_cover": 84.456044,
  "grid:code": "MGRS-30NYK",
  "processing:level": "L2A",
  "view:incidence_angle": 9.82920248878181,
  "created": "2019-08-05T14:29:54Z",
  "sentinel:product_id": "S2A_MSIL2A_20150704T101006_N0204_R022_T30NYK_20150704T102420",
  "view:sun_azimuth": 49.058168068692,
  "sentinel:datastrip_id": "S2A_USER_MSI_L2A_DS_EPA__20160808T224207_S20150704T102420_N02.04",
  "sentinel:processing_baseline": "02.04",
  "proj:bbox": [],
  "proj:epsg": 32630,
  "bdap:additional_attributes": {},
  "processed": "2019-08-05T14:53:58.579614Z",
  "mission": "Sentinel-2",
  "view:azimuth": 100.76592332834346,
  "gsd": 10,
  "sat:absolute_orbit": 162,
  "sentinel:acquisition_station": "EPA_"
}
@jonhealy1
Copy link
Collaborator

By default, the FieldsExtension spec in the stac-fastapi parent library only includes one property, datetime .
https://github.com/stac-utils/stac-fastapi/blob/4fb10ec6ba758f28ddef749ea7bac6fbb5963f9b/stac_fastapi/extensions/stac_fastapi/extensions/core/fields/fields.py#L46

@jonhealy1
Copy link
Collaborator

To get all your properties do this: http://localhost:8080/search?fields+properties&limit=10

@iliion
Copy link
Author

iliion commented Mar 23, 2024 via email

@jonhealy1
Copy link
Collaborator

I am guessing they only include one property because there are many very large stac datasets out there online and returning the minimum amount of information makes a lot of sense. Especially if you're only displaying items on a map I guess. I would make this an issue in the stac-fastapi parent repo. With a small limit and if you're using pagination, it doesn't really offer any performance benefits to hide most of the properties.

@jonhealy1
Copy link
Collaborator

They should be following the stac api spec though ideally.

@iliion
Copy link
Author

iliion commented Mar 23, 2024 via email

@jonhealy1
Copy link
Collaborator

You can just do +properties to show all the properties like this http://localhost:8080/search?fields+properties&limit=10

@jonhealy1
Copy link
Collaborator

It would be interesting to see what people think over there

@iliion
Copy link
Author

iliion commented Mar 25, 2024

I think it would be best to follow the STAC API specs https://api.stacspec.org/v1.0.0/item-search/

There are also implementations like STAC Browser that use the search endpoint in order to return items. As a user I would expect to see all the properties of an Item.

@jonhealy1
Copy link
Collaborator

Would you mind adding the issue here? This is where the relevant issue comes from. https://github.com/stac-utils/stac-fastapi/issues

@vincentsarago
Copy link
Member

🤔 it's interesting, there is a different behaviour between -elasticsearch and -pgstac.

PgSTAC does not use the PostFieldsExtension. filter_fields as ElasticSearch is doing in https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/987f0b924b45e3f63302758b6e63d38ba504964f/stac_fastapi/core/stac_fastapi/core/core.py#L593C12-L593C64

and will in fact does not rely on default_includes 😅 (This is a BUG or a feature?).

POST

$ curl --header "Content-Type: application/json" --request POST --data '{"fields":{},"limit":1}' https://stac.eoapi.dev/search | jq '.features[0].properties'
{
  "created": "2023-12-19T07:04:49.631129Z",
  "license": "CC-BY-4.0",
  "mission": "umbra-sample-data",
  "updated": "2023-12-19T07:04:49.631129Z",
  "datetime": "2023-12-01T19:20:52Z",
  "platform": "UMBRA_08",
  "providers": [
    {
      "url": "https://umbra.space",
      "name": "umbra",
      "roles": [
        "host",
        "processor",
        "producer",
        "licensor"
      ]
    }
  ],
  "end_datetime": "2023-12-01T19:20:53.654917Z",
  "constellation": "umbra",
  "start_datetime": "2023-12-01T19:20:52Z",
  "sar:looks_range": 1,
  "sar:product_type": "GEC",
  "sar:looks_azimuth": 1,
  "sar:polarizations": [
    "VV"
  ],
  "sar:frequency_band": "X",
  "sar:instrument_mode": "SPOTLIGHT",
  "sar:center_frequency": 9.600010292488152,
  "sar:resolution_range": 0.8346077999881579,
  "view:incidence_angle": 50.55698046197228,
  "sar:resolution_azimuth": 0.852999818905946,
  "sar:observation_direction": "left"
}

$ curl --header "Content-Type: application/json" --request POST --data '{"fields":{"include":["properties.end_datetime"]},"limit":1}' https://stac.eoapi.dev/search | jq '.features[0].properties'
{
  "end_datetime": "2023-12-01T19:20:53.654917Z"
}

GET

$ curl --header "Content-Type: application/json"  https://stac.eoapi.dev/search\?limit\=1 | jq '.features[0].properties'
{
  "created": "2023-12-19T07:04:49.631129Z",
  "license": "CC-BY-4.0",
  "mission": "umbra-sample-data",
  "updated": "2023-12-19T07:04:49.631129Z",
  "datetime": "2023-12-01T19:20:52Z",
  "platform": "UMBRA_08",
  "providers": [
    {
      "url": "https://umbra.space",
      "name": "umbra",
      "roles": [
        "host",
        "processor",
        "producer",
        "licensor"
      ]
    }
  ],
  "end_datetime": "2023-12-01T19:20:53.654917Z",
  "constellation": "umbra",
  "start_datetime": "2023-12-01T19:20:52Z",
  "sar:looks_range": 1,
  "sar:product_type": "GEC",
  "sar:looks_azimuth": 1,
  "sar:polarizations": [
    "VV"
  ],
  "sar:frequency_band": "X",
  "sar:instrument_mode": "SPOTLIGHT",
  "sar:center_frequency": 9.600010292488152,
  "sar:resolution_range": 0.8346077999881579,
  "view:incidence_angle": 50.55698046197228,
  "sar:resolution_azimuth": 0.852999818905946,
  "sar:observation_direction": "left"
}

$ curl --header "Content-Type: application/json"  https://stac.eoapi.dev/search\?limit\=1\&fields\=properties.end_datetime | jq '.features[0].properties'
{
  "end_datetime": "2023-12-01T19:20:53.654917Z"
}

@vincentsarago
Copy link
Member

I think I'm going to propose that we deprecate the default_includes, because:

  • it's only used in POST request, while both GET and POST should return the same thing (IMO)
  • it seems up to the backend implementers to use it
  • I think it will make more sense to set defaults include/exclude directly in the FieldsExtensionGetRequest and FieldsExtensionPostRequest object

jonhealy1 added a commit that referenced this issue Jun 16, 2024
**Related Issue(s):**

- #217 
- stac-utils/stac-fastapi#642
-
stac-utils/stac-fastapi@d8528ae

**Description:**

- Update to stac-fastapi v3.0.0a3
- Remove deprecated filter_fields
- Default to returning all properties, copy stac-fastapi-pgstac
behaviour for now


**PR Checklist:**

- [x] Code is formatted and linted (run `pre-commit run --all-files`)
- [x] Tests pass (run `make test`)
- [x] Documentation has been updated to reflect changes, if applicable
- [x] Changes are added to the changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants