Skip to content

feat(search-index): add search-index export and import commands#105

Merged
rs-amp merged 13 commits into
amplience:masterfrom
rs-amp:feature/search-index
Jan 6, 2022
Merged

feat(search-index): add search-index export and import commands#105
rs-amp merged 13 commits into
amplience:masterfrom
rs-amp:feature/search-index

Conversation

@rs-amp
Copy link
Copy Markdown
Contributor

@rs-amp rs-amp commented Aug 16, 2021

This PR adds search index export and import commands.

The export command is rather straightforward - it scans all search indexes in the hub, enriches them with related info such as its settings, assigned content types, keys and replicas, and dumps them to a JSON file for each index. Replicas do not appear as individual files - they are contained within their parent search index's file.

Webhooks are also exported with each search index, into the webhooks/ subfolder of the target directory. These include their webhook id, which is referenced by the fields of EnrichedAssignedContentType so that the webhook can be found from these files when importing.

On import, search indexes are created or updated depending on if a match with the same name is found, and if its content does not match the search index being imported. Settings are synchronised afterwards, including a list of all replicas. The import uses a union of both the existing replicas and the replicas in the import file to determine what replicas to put in the settings, and update the settings of. Replicas are never deleted - as their names are unique and reserved, deleting them would cause issues.

Assigned content types are created automatically, and will try to sync with what you are importing - including deleting assignments that are not present on the file being imported. By default, each assigned content type uses the default webhooks created when the type was created - or the existing webhooks if the assignment already existed.

Optionally, the user can provide a --webhooks flag, which allows importing webhooks relating to assigned content types within search indexes. When importing webhooks, the command attempts to rewrite occurrences of the withDeliveryContentItem tag within the webhook body to point to the target hub's name and virtual staging environment. If different, this new body and any other related properties are copied to the target webhook.

A clone step is also added for search indexes, which occurs immediately before content item import, so that step triggers any webhooks. Similar to extensions, the revert version of this step does not delete search indexes, as the names are unique and reserved on creation. Deleting them might make them impossible to recreate in the future, so we prefer to leave them alive to update in the future instead.

@rs-amp rs-amp requested a review from easen-amp August 16, 2021 14:23
Comment thread src/commands/hub/steps/settings-clone-step.ts Outdated
@rs-amp
Copy link
Copy Markdown
Contributor Author

rs-amp commented Sep 15, 2021

Depends on amplience/dc-management-sdk-js#95. After that's merged, package.json must be updated.

@rs-amp rs-amp force-pushed the feature/search-index branch from 8b40a45 to 5fafc0d Compare September 15, 2021 09:59
@rs-amp rs-amp merged commit ebfaf0b into amplience:master Jan 6, 2022
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.

3 participants