stac-utils / stac-fastapi-elasticsearch-opensearch

Elasticsearch backend for stac-fastapi with Opensearch support.
https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch
MIT License
31 stars 13 forks source link

IS NULL filter operator #300

Open jamesfisher-geo opened 1 month ago

jamesfisher-geo commented 1 month ago

Describe the bug IS NULL is included in the filter extension logic. However, I cannot get it to work with cql2-json or cql2-text. https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/blob/2d6cb4dabb5847fa22e4734187779dcbcb7b41b9/stac_fastapi/core/stac_fastapi/core/extensions/filter.py#L74

To Reproduce Steps to reproduce the behavior:

  1. docker compose up app-opensearch or docker compose up app-elasticsearch
  2. python3 data_loader.py --base-url http://localhost:8082
  3. Try the following: POST http://localhost:8082/search body
    
    {
    "filter-lang": "cql2-json",
    "filter": {
            "op": "isNull",
            "args": [ { "property": "sentinel:data_coverage" } ]
          }

}

```json
{
    "detail": "Error with cql2_json filter: Q() can only accept dict with a single query ({\"match\": {...}}). Instead it got ({})"
}

GET http://localhost:8082/search?filter=sentinel:data_coverage > 50 OR landsat:coverage_percent < 10 OR (sentinel:data_coverage IS NULL AND landsat:coverage_percent IS NULL)

{
    "detail": "Error with cql2_json filter: Q() can only accept dict with a single query ({\"match\": {...}}). Instead it got ({})"
}

Expected behavior valid ItemCollection

jamesfisher-geo commented 1 week ago

For full implementation we are waiting on a new version of pygeofilter

jamesfisher-geo commented 5 days ago

It is possible that we could migrate the cql2 parsing logic to use cql-rs Python bindings