#!/bin/bash # ---------------------------------------------- # usage() function - prints help/usage message # ---------------------------------------------- usage() { cat < OPENSEARCH_MODEL_ID= in .env.local. After running this script, you will need to remove and rebuild your containers using "sndev stop" and "sndev start", in order to enable semantic search. Options: -h, --help Display this help message and exit Arguments: KW_INDEX The name of the keyword index (default: item) NLP_INDEX The name of the semantic index (default: item-nlp) EOF } # ------------------------------------------------- # Check if user requested help via -h or --help # ------------------------------------------------- for arg in "$@"; do case "$arg" in -h|--help) usage exit 0 ;; esac done # --------------------------------------- # Set defaults if not provided # --------------------------------------- KW_INDEX="${1:-item}" NLP_INDEX="${2:-item-nlp}" # --------------------------------------- # Main script # --------------------------------------- OS_URL="http://localhost:9200" MODEL_NAME="huggingface/sentence-transformers/all-mpnet-base-v2" set -e # Ensure that search is in COMPOSE_PROFILES COMPOSE_PROFILES=$(docker exec app printenv COMPOSE_PROFILES) if [[ ! "$COMPOSE_PROFILES" == *"search"* ]]; then cat <> ".env.local" fi if grep -q "^OPENSEARCH_MODEL_ID=" ".env.local"; then sed -i '' "s|^OPENSEARCH_MODEL_ID=.*|OPENSEARCH_MODEL_ID=$model_id|" ".env.local" else echo "OPENSEARCH_MODEL_ID=$model_id" >> ".env.local" fi echo "done." cat < ./sndev restart Do NOT rebuild the stackernews_os volume or you will have to run this process again. EOF