Skip to content

Add search re-index script for the dev envs #2814

Description

@AlexSkrypnyk
#!/usr/bin/env bash
##
# Index search.
#
# shellcheck disable=SC2086

set -eu
[ "${VORTEX_DEBUG-}" = "1" ] && set -x

# ------------------------------------------------------------------------------

info() { printf "   ==> %s\n" "${1}"; }
task() { printf "     > %s\n" "${1}"; }
note() { printf "       %s\n" "${1}"; }

drush() { ./vendor/bin/drush -y "$@"; }

DRUPAL_INDEX_CONTENT_SKIP="${DRUPAL_INDEX_CONTENT_SKIP:-0}"

info "Started search indexing operations."

environment="$(drush php:eval "print \Drupal\core\Site\Settings::get('environment');")"
note "Environment: ${environment}"

note "Search indexing skip: ${DRUPAL_INDEX_CONTENT_SKIP}"
if [ "${DRUPAL_INDEX_CONTENT_SKIP}" = "1" ]; then
  note "Skipping search indexing."
  info "Finished search indexing operations."
  exit 0
fi

if echo "${environment}" | grep -q -e local -e ci -e dev -e stage; then
  task "Resetting search index tracker."
  drush search-api:reset-tracker

  task "Starting search indexing."
  drush search-api:index
else
  note "Skipping search indexing in non-development environment."
fi

info "Finished search indexing operations."

Also need to update docs to explain how to opt-out from this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A3Board worker 3ConfirmedThe issue was triaged and confirmed for development

    Type

    No type

    Projects

    Status
    Release queue

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions