You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用stac-fastapi Search API时OR条件查询报错,求正确写法

正确构造stac-fastapi Search API的OR条件查询请求

要解决RequestValidationError问题,你需要严格按照stac-fastapi的查询规则构造OR条件,核心是把多个合法查询条件放入query.or数组中,每个条件仅使用允许的操作符(eq、ne、lt、lte、gt、gte)。

示例请求体

以查询云量小于10或平台为Sentinel-2的影像为例,正确的POST请求JSON体如下:

{
  "query": {
    "or": [
      {
        "eo:cloud_cover": {
          "lt": 10
        }
      },
      {
        "platform": {
          "eq": "Sentinel-2"
        }
      }
    ]
  }
}

关键注意事项

  • or字段的值必须是数组,每个元素是一个独立的属性查询对象
  • 每个查询对象只能使用官方允许的操作符,不能自定义操作符
  • 可同时组合and条件实现更复杂的逻辑,比如:
{
  "query": {
    "and": [
      {
        "eo:cloud_cover": {
          "lte": 20
        }
      },
      {
        "or": [
          {
            "platform": {
              "eq": "Sentinel-2"
            }
          },
          {
            "platform": {
              "eq": "Landsat-8"
            }
          }
        ]
      }
    ]
  }
}

内容的提问来源于stack exchange,提问作者Esteban Lombardozzi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 18:44:56