Skip to content

Commit e7330dc

Browse files
update CQL2 BETWEEN syntax
1 parent 7bf41c6 commit e7330dc

File tree

4 files changed

+8
-39
lines changed

4 files changed

+8
-39
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
filter_extension = FilterExtension(client=EsAsyncBaseFiltersClient())
2828
filter_extension.conformance_classes.append(
29-
"http://www.opengis.net/spec/cql2/1.0/req/advanced-comparison-operators"
29+
"http://www.opengis.net/spec/cql2/1.0/conf/advanced-comparison-operators"
3030
)
3131

3232
extensions = [

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/extensions/filter.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,16 @@ def to_es(self):
191191
"wildcard": {
192192
to_es(self.args[0]): {
193193
"value": cql2_like_to_es(str(to_es(self.args[1]))),
194-
"case_insensitive": "true",
194+
"case_insensitive": "false",
195195
}
196196
}
197197
}
198198
elif self.op == AdvancedComparisonOp.between:
199-
if not isinstance(self.args[1], List):
200-
raise RuntimeError(f"Arg {self.args[1]} is not a list")
201199
return {
202200
"range": {
203201
to_es(self.args[0]): {
204-
"gte": to_es(self.args[1][0]),
205-
"lte": to_es(self.args[1][1]),
202+
"gte": to_es(self.args[1]),
203+
"lte": to_es(self.args[2]),
206204
}
207205
}
208206
}

stac_fastapi/elasticsearch/tests/extensions/cql2/example21.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
{
88
"property": "cloud_cover"
99
},
10-
[
11-
0.1,
12-
0.2
13-
]
10+
0.1,
11+
0.2
1412
]
1513
},
1614
{

stac_fastapi/elasticsearch/tests/extensions/test_filter.py

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -369,31 +369,6 @@ async def test_search_filter_extension_in_no_list(app_client, ctx):
369369
async def test_search_filter_extension_between(app_client, ctx):
370370
sun_elevation = ctx.item["properties"]["view:sun_elevation"]
371371

372-
params = {
373-
"filter": {
374-
"op": "and",
375-
"args": [
376-
{"op": "=", "args": [{"property": "id"}, ctx.item["id"]]},
377-
{
378-
"op": "between",
379-
"args": [
380-
{"property": "properties.view:sun_elevation"},
381-
[sun_elevation - 0.01, sun_elevation + 0.01],
382-
],
383-
},
384-
],
385-
}
386-
}
387-
resp = await app_client.post("/search", json=params)
388-
389-
assert resp.status_code == 200
390-
assert len(resp.json()["features"]) == 1
391-
392-
393-
@pytest.mark.asyncio
394-
async def test_search_filter_extension_between_no_list(app_client, ctx):
395-
sun_elevation = ctx.item["properties"]["view:sun_elevation"]
396-
397372
params = {
398373
"filter": {
399374
"op": "and",
@@ -412,7 +387,5 @@ async def test_search_filter_extension_between_no_list(app_client, ctx):
412387
}
413388
resp = await app_client.post("/search", json=params)
414389

415-
assert resp.status_code == 400
416-
assert resp.json() == {
417-
"detail": f"Error with cql2_json filter: Arg {sun_elevation - 0.01} is not a list"
418-
}
390+
assert resp.status_code == 200
391+
assert len(resp.json()["features"]) == 1

0 commit comments

Comments
 (0)