Skip to content

create indexes at startup rather than when ingesting, add collection index schema #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 16, 2022

Conversation

philvarner
Copy link
Collaborator

Related Issue(s):

Description:

  1. Create indexes at startup instead of checking and creating if non-existent when ingesting
  2. add a schema for the collections index

PR Checklist:

  • Code is formatted and linted (run pre-commit run --all-files)
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the changelog

def all_collections(self, **kwargs) -> Collections:
"""Read all collections from the database."""
base_url = str(kwargs["request"].base_url)
try:
collections = self.client.search(
index="stac_collections", doc_type="_doc", query={"match_all": {}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc_type is deprecated, and is assumed to be _doc

def item_collection(
self, collection_id: str, limit: int = 10, **kwargs
self, collection_id: str, limit: int = 10, token: str = None, **kwargs
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated this signature wrt the ABC

def post_search(
self, search_request: BaseSearchPostRequest, **kwargs
) -> ItemCollection:
def post_search(self, search_request: Search, **kwargs) -> ItemCollection:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated wrt the ABC

session: Session = attr.ib(default=attr.Factory(Session.create_from_env))
client = ElasticsearchSettings().create_client

ES_MAPPINGS_DYNAMIC_TEMPLATES = [
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copied from transactions.py.

},
}

ES_COLLECTIONS_MAPPINGS = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a mapping for collections -- same one used in stac-server

@philvarner philvarner merged commit c4cbd0d into main Mar 16, 2022
@philvarner philvarner deleted the pv/create_indexes_at_startup branch March 16, 2022 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants