CQL支持
提供商
到目前为止,支持CQL筛选的可用提供程序仅限于 Elasticsearch 和 PostgreSQL 。
限制
CQL的支持仅限于 Simple CQL filter 因此,它允许使用以下谓词进行查询:
比较谓词
空间谓词
时态谓词
格式
目前,Elasticearch只支持使用JSON编码的CQL方言 CQL-JSON 。
PostgreSQL同时支持CQL-JSON和CQL-Text方言, CQL-JSON 和 CQL-TEXT
查询
PostgreSQL提供程序使用 pygeofilter 允许一系列筛选器表达式,请参阅以下示例:
使用Elasticearch,目前支持以下类型的查询:
between
谓词查询逻辑上的
and
查询方式:between
和eq
表达式空间查询,使用
bbox
示例
A BETWEEN
通过HTTP POST请求的特定属性的示例:
curl --location --request POST 'http://localhost:5000/collections/nhsl_hazard_threat_all_indicators_s_bc/items?f=json&limit=50&filter-lang=cql-json' \
--header 'Content-Type: application/query-cql-json' \
--data-raw '{
"between": {
"value": { "property": "properties.MHn_Intensity" },
"lower": 0.59,
"upper": 0.60
}
}'
或
curl --location --request POST 'http://localhost:5000/collections/recentearthquakes/items?f=json&limit=10&filter-lang=cql-json'
--header 'Content-Type: application/query-cql-json'
--data-raw '{
"between":{
"value":{"property": "ml"},
"lower":4,
"upper":4.5
}
}'
相同 BETWEEN
使用格式为CQL文本、URL编码如下的HTTP GET请求进行查询:
curl "http://localhost:5000/collections/recentearthquakes/items?f=json&limit=10&filter=ml%20BETWEEN%204%20AND%204.5"
一个 EQUALS
特定属性的示例:
curl --location --request POST 'http://localhost:5000/collections/recentearthquakes/items?f=json&limit=10&filter-lang=cql-json'
--header 'Content-Type: application/query-cql-json'
--data-raw '{
"eq":[{"property": "user_entered"},"APBE"]
}'
A CROSSES
示例通过HTTP GET请求。CQL文本通过 filter
参数。
curl "http://localhost:5000/collections/hot_osm_waterways/items?f=json&filter=CROSSES(foo_geom,%20LINESTRING(28%20-2,%2030%20-4))"
请注意,CQL文本已经过URL编码。这在cURL命令中是必需的,但在浏览器中输入时,可以使用纯文本,例如 CROSSES(foo_geom, LINESTRING(28 -2, 30 -4))
。