Skip to content

Module stac_fastapi.core.database_logic

Database logic core.

Variables

COLLECTIONS_INDEX
DEFAULT_SORT
ES_COLLECTIONS_MAPPINGS
ES_INDEX_NAME_UNSUPPORTED_CHARS
ES_ITEMS_MAPPINGS
ES_ITEMS_SETTINGS
ES_MAPPINGS_DYNAMIC_TEMPLATES
ITEMS_INDEX_PREFIX
ITEM_INDICES

Functions

index_alias_by_collection_id

def index_alias_by_collection_id(
    collection_id: str
) -> str

Translate a collection id into an Elasticsearch index alias.

Parameters:

Name Type Description Default
collection_id str The collection id to translate into an index alias. None

Returns:

Type Description
str The index alias derived from the collection id.

index_by_collection_id

def index_by_collection_id(
    collection_id: str
) -> str

Translate a collection id into an Elasticsearch index name.

Parameters:

Name Type Description Default
collection_id str The collection id to translate into an index name. None

Returns:

Type Description
str The index name derived from the collection id.

indices

def indices(
    collection_ids: Optional[List[str]]
) -> str

Get a comma-separated string of index names for a given list of collection ids.

Parameters:

Name Type Description Default
collection_ids None A list of collection ids. None

Returns:

Type Description
None A string of comma-separated index names. If collection_ids is empty, returns the default indices.

mk_actions

def mk_actions(
    collection_id: str,
    processed_items: List[stac_fastapi.types.stac.Item]
) -> List[Dict[str, Any]]

Create Elasticsearch bulk actions for a list of processed items.

Parameters:

Name Type Description Default
collection_id str The identifier for the collection the items belong to. None
processed_items List[Item] The list of processed items to be bulk indexed. None

Returns:

Type Description
List[Dict[str, Union[str, Dict]]] The list of bulk actions to be executed,
each action being a dictionary with the following keys:
- _index: the index to store the document in.
- _id: the document's identifier.
- _source: the source of the document.

mk_item_id

def mk_item_id(
    item_id: str,
    collection_id: str
) -> str

Create the document id for an Item in Elasticsearch.

Parameters:

Name Type Description Default
item_id str The id of the Item. None
collection_id str The id of the Collection that the Item belongs to. None

Returns:

Type Description
str The document id for the Item, combining the Item id and the Collection id, separated by a | character.

Classes

Geometry

class Geometry(
    *args,
    **kwargs
)

Base class for protocol classes.

Protocol classes are defined as::

class Proto(Protocol):
    def meth(self) -> int:
        ...

Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing), for example::

class C:
    def meth(self) -> int:
        return 0

def func(x: Proto) -> int:
    return x.meth()

func(C())  # Passes static type check

See PEP 544 for details. Protocol classes decorated with

Ancestors (in MRO)

  • typing.Protocol
  • typing.Generic