Skip to content

Commit 562f7b3

Browse files
authored
Merge branch 'main' into add-image
2 parents c033dfb + 5ab4c4b commit 562f7b3

File tree

5 files changed

+109
-104
lines changed

5 files changed

+109
-104
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515
### Changed
1616
- Updated the `publish.yml` workflow to include Docker image publishing to GitHub Container Registry [#311](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/311)
1717
- Improved the README with detailed descriptions of the new Docker images, providing guidance for images. [#311](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/311)
18+
- Aggregation ElasticSearch `total_count` bugfix, moved aggregation text to docs. [#314](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/314)
1819

1920
## [v3.2.0] - 2024-10-09
2021

README.md

Lines changed: 1 addition & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -315,111 +315,9 @@ The modified Items with lowercase identifiers will now be visible to users acces
315315

316316
Authentication is an optional feature that can be enabled through `Route Dependencies` examples can be found and a more detailed explanation in [examples/auth](examples/auth).
317317

318-
319318
## Aggregation
320319

321-
Sfeos supports the STAC API [Aggregation Extension](https://github.com/stac-api-extensions/aggregation). This enables geospatial aggregation of points and geometries, as well as frequency distribution aggregation of any other property including dates. Aggregations can be defined at the root Catalog level (`/aggregations`) and at the Collection level (`/<collection_id>/aggregations`). The `/aggregate` route also fully supports base search and the STAC API [Filter Extension](https://github.com/stac-api-extensions/filter). Any query made with `/search` may also be executed with `/aggregate`, provided that the relevant aggregation fields are available,
322-
323-
324-
A field named `aggregations` should be added to the Collection object for the collection for which the aggregations are available, for example:
325-
326-
```json
327-
"aggregations": [
328-
{
329-
"name": "total_count",
330-
"data_type": "integer"
331-
},
332-
{
333-
"name": "datetime_max",
334-
"data_type": "datetime"
335-
},
336-
{
337-
"name": "datetime_min",
338-
"data_type": "datetime"
339-
},
340-
{
341-
"name": "datetime_frequency",
342-
"data_type": "frequency_distribution",
343-
"frequency_distribution_data_type": "datetime"
344-
},
345-
{
346-
"name": "sun_elevation_frequency",
347-
"data_type": "frequency_distribution",
348-
"frequency_distribution_data_type": "numeric"
349-
},
350-
{
351-
"name": "platform_frequency",
352-
"data_type": "frequency_distribution",
353-
"frequency_distribution_data_type": "string"
354-
},
355-
{
356-
"name": "sun_azimuth_frequency",
357-
"data_type": "frequency_distribution",
358-
"frequency_distribution_data_type": "numeric"
359-
},
360-
{
361-
"name": "off_nadir_frequency",
362-
"data_type": "frequency_distribution",
363-
"frequency_distribution_data_type": "numeric"
364-
},
365-
{
366-
"name": "cloud_cover_frequency",
367-
"data_type": "frequency_distribution",
368-
"frequency_distribution_data_type": "numeric"
369-
},
370-
{
371-
"name": "grid_code_frequency",
372-
"data_type": "frequency_distribution",
373-
"frequency_distribution_data_type": "string"
374-
},
375-
{
376-
"name": "centroid_geohash_grid_frequency",
377-
"data_type": "frequency_distribution",
378-
"frequency_distribution_data_type": "string"
379-
},
380-
{
381-
"name": "centroid_geohex_grid_frequency",
382-
"data_type": "frequency_distribution",
383-
"frequency_distribution_data_type": "string"
384-
},
385-
{
386-
"name": "centroid_geotile_grid_frequency",
387-
"data_type": "frequency_distribution",
388-
"frequency_distribution_data_type": "string"
389-
},
390-
{
391-
"name": "geometry_geohash_grid_frequency",
392-
"data_type": "frequency_distribution",
393-
"frequency_distribution_data_type": "numeric"
394-
},
395-
{
396-
"name": "geometry_geotile_grid_frequency",
397-
"data_type": "frequency_distribution",
398-
"frequency_distribution_data_type": "string"
399-
}
400-
]
401-
```
402-
403-
Available aggregations are:
404-
405-
- total_count (count of total items)
406-
- collection_frequency (Item `collection` field)
407-
- platform_frequency (Item.Properties.platform)
408-
- cloud_cover_frequency (Item.Properties.eo:cloud_cover)
409-
- datetime_frequency (Item.Properties.datetime, monthly interval)
410-
- datetime_min (earliest Item.Properties.datetime)
411-
- datetime_max (latest Item.Properties.datetime)
412-
- sun_elevation_frequency (Item.Properties.view:sun_elevation)
413-
- sun_azimuth_frequency (Item.Properties.view:sun_azimuth)
414-
- off_nadir_frequency (Item.Properties.view:off_nadir)
415-
- grid_code_frequency (Item.Properties.grid:code)
416-
- centroid_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.Properties.proj:centroid)
417-
- centroid_geohex_grid_frequency ([geohex grid](https://opensearch.org/docs/latest/aggregations/bucket/geohex-grid/) on Item.Properties.proj:centroid)
418-
- centroid_geotile_grid_frequency (geotile on Item.Properties.proj:centroid)
419-
- geometry_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.geometry)
420-
- geometry_geotile_grid_frequency ([geotile grid](https://opensearch.org/docs/latest/aggregations/bucket/geotile-grid/) on Item.geometry)
421-
422-
Support for additional fields and new aggregations can be added in the associated `database_logic.py` file.
320+
Aggregation of points and geometries, as well as frequency distribution aggregation of any other property including dates is supported in stac-fatsapi-elasticsearch-opensearch. Aggregations can be defined at the root Catalog level (`/aggregations`) and at the Collection level (`/<collection_id>/aggregations`). Details for supported aggregations can be found at [./docs/src/aggregation.md](./docs/src/aggregation.md)
423321

424322
## Rate Limiting
425323

docs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ nav:
5252
- session: api/stac_fastapi/core/session.md
5353
- utilities: api/stac_fastapi/core/utilities.md
5454
- version: api/stac_fastapi/core/version.md
55+
- Aggregation: "aggregation.md"
5556
- Development - Contributing: "contributing.md"
5657
- Release Notes: "release-notes.md"
5758

docs/src/aggregation.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
## Aggregation
2+
3+
Stac-fatsapi-elasticsearch-opensearch supports the STAC API [Aggregation Extension](https://github.com/stac-api-extensions/aggregation). This enables aggregation of points and geometries, as well as frequency distribution aggregation of any other property including dates. Aggregations can be defined at the root Catalog level (`/aggregations`) and at the Collection level (`/<collection_id>/aggregations`). The [Filter Extension](https://github.com/stac-api-extensions/filter) is also fully supported, enabling aggregated returns of search queries. Any query made with `/search` may also be executed with `/aggregate`, provided that the relevant aggregation fields are available,
4+
5+
A field named `aggregations` should be added to the Collection object for the collection for which the aggregations are available, for example:
6+
7+
Available aggregations are:
8+
9+
- total_count (count of total items)
10+
- collection_frequency (Item `collection` field)
11+
- platform_frequency (Item.Properties.platform)
12+
- cloud_cover_frequency (Item.Properties.eo:cloud_cover)
13+
- datetime_frequency (Item.Properties.datetime, monthly interval)
14+
- datetime_min (earliest Item.Properties.datetime)
15+
- datetime_max (latest Item.Properties.datetime)
16+
- sun_elevation_frequency (Item.Properties.view:sun_elevation)
17+
- sun_azimuth_frequency (Item.Properties.view:sun_azimuth)
18+
- off_nadir_frequency (Item.Properties.view:off_nadir)
19+
- grid_code_frequency (Item.Properties.grid:code)
20+
- centroid_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.Properties.proj:centroid)
21+
- centroid_geohex_grid_frequency ([geohex grid](https://opensearch.org/docs/latest/aggregations/bucket/geohex-grid/) on Item.Properties.proj:centroid)
22+
- centroid_geotile_grid_frequency (geotile on Item.Properties.proj:centroid)
23+
- geometry_geohash_grid_frequency ([geohash grid](https://opensearch.org/docs/latest/aggregations/bucket/geohash-grid/) on Item.geometry)
24+
- geometry_geotile_grid_frequency ([geotile grid](https://opensearch.org/docs/latest/aggregations/bucket/geotile-grid/) on Item.geometry)
25+
26+
Support for additional fields and new aggregations can be added in the [OpenSearch database_logic.py](../../stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py) and [ElasticSearch database_logic.py](../../stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py) files.
27+
28+
```json
29+
"aggregations": [
30+
{
31+
"name": "total_count",
32+
"data_type": "integer"
33+
},
34+
{
35+
"name": "datetime_max",
36+
"data_type": "datetime"
37+
},
38+
{
39+
"name": "datetime_min",
40+
"data_type": "datetime"
41+
},
42+
{
43+
"name": "datetime_frequency",
44+
"data_type": "frequency_distribution",
45+
"frequency_distribution_data_type": "datetime"
46+
},
47+
{
48+
"name": "sun_elevation_frequency",
49+
"data_type": "frequency_distribution",
50+
"frequency_distribution_data_type": "numeric"
51+
},
52+
{
53+
"name": "platform_frequency",
54+
"data_type": "frequency_distribution",
55+
"frequency_distribution_data_type": "string"
56+
},
57+
{
58+
"name": "sun_azimuth_frequency",
59+
"data_type": "frequency_distribution",
60+
"frequency_distribution_data_type": "numeric"
61+
},
62+
{
63+
"name": "off_nadir_frequency",
64+
"data_type": "frequency_distribution",
65+
"frequency_distribution_data_type": "numeric"
66+
},
67+
{
68+
"name": "cloud_cover_frequency",
69+
"data_type": "frequency_distribution",
70+
"frequency_distribution_data_type": "numeric"
71+
},
72+
{
73+
"name": "grid_code_frequency",
74+
"data_type": "frequency_distribution",
75+
"frequency_distribution_data_type": "string"
76+
},
77+
{
78+
"name": "centroid_geohash_grid_frequency",
79+
"data_type": "frequency_distribution",
80+
"frequency_distribution_data_type": "string"
81+
},
82+
{
83+
"name": "centroid_geohex_grid_frequency",
84+
"data_type": "frequency_distribution",
85+
"frequency_distribution_data_type": "string"
86+
},
87+
{
88+
"name": "centroid_geotile_grid_frequency",
89+
"data_type": "frequency_distribution",
90+
"frequency_distribution_data_type": "string"
91+
},
92+
{
93+
"name": "geometry_geohash_grid_frequency",
94+
"data_type": "frequency_distribution",
95+
"frequency_distribution_data_type": "numeric"
96+
},
97+
{
98+
"name": "geometry_geotile_grid_frequency",
99+
"data_type": "frequency_distribution",
100+
"frequency_distribution_data_type": "string"
101+
}
102+
]
103+
```
104+
105+

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def indices(collection_ids: Optional[List[str]]) -> str:
168168
Returns:
169169
A string of comma-separated index names. If `collection_ids` is None, returns the default indices.
170170
"""
171-
if collection_ids is None:
171+
if collection_ids is None or collection_ids == []:
172172
return ITEM_INDICES
173173
else:
174174
return ",".join([index_by_collection_id(c) for c in collection_ids])

0 commit comments

Comments
 (0)