This repository has been archived on 2025-04-28. You can view files and clone it, but cannot push or open issues or pull requests.
solr-shard-management/solr-create.sh

41 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
. ./setenv.sh
ARG_SOLR_SHARD_IDS=$1
ARG_SOLR_SHARDS=$2
ARG_SOLR_NODE_ID=$3
ARG_SOLR_NODES=$4
ARG_SOLR_SHARD_RANGE=$5
if [[ ! -z "$ARG_SOLR_SHARD_IDS" ]]; then
if [[ -z "$ARG_SOLR_SHARDS" ]]; then
echo "The expected number of shards is required"
exit 1
fi
if [[ -z "$ARG_SOLR_NODE_ID" ]]; then
ARG_SOLR_NODE_ID=1
echo "A Solr instance node ID was not specified; using '1'"
fi
if [[ -z "$ARG_SOLR_NODES" ]]; then
ARG_SOLR_NODES=1
echo "A total number of Solr instances was not specified; using '1'"
fi
if [[ ! -z "$ARG_SOLR_SHARD_RANGE" ]]; then
SOLR_EXTRA="&property.shard.range=$ARG_SOLR_SHARD_RANGE&property.shard.instance=$ARG_SOLR_SHARD_IDS"
fi
echo "Creating a shard core in the Solr instance ..."
SOLR_URL="${SOLR_BASEURL}/admin/cores?action=newCore&core=${SOLR_CORE}&storeRef=workspace://SpacesStore&numShards=${ARG_SOLR_SHARDS}&nodeInstance=${ARG_SOLR_NODE_ID}&numNodes=${ARG_SOLR_NODES}&template=${SOLR_TEMPLATE}&shardIds=${ARG_SOLR_SHARD_IDS}${SOLR_EXTRA}"
else
echo "No arguments were specified; creating a shard-less core in the Solr instance ..."
SOLR_URL="${SOLR_BASEURL}/admin/cores?action=newCore&core=${SOLR_CORE}&storeRef=workspace://SpacesStore&template=${SOLR_TEMPLATE}"
fi
if [[ ! -z "$DEBUG" ]]; then
echo "URL: ${SOLR_URL}"
fi
curl -SsL ${SOLR_URL}