Skip to main content

Switching from Solr to Elasticsearch in PoolParty

This section provides instructions for transitioning from Solr to Elasticsearch as the indexing service within PoolParty's Semantic Middleware Configurator.

This procedure involves executing a script to re-configure the system to use Elasticsearch without migrating any existing data.

Prerequisites

  • Solr must be currently configured and operational as your indexing service in PoolParty.

  • This guide solely covers switching the indexing service to Elasticsearch and does not include any data migration procedures.

Guide

  1. Prepare the environment

    1. Stop PoolParty  ./bin/poolparty stop

    2. Copy the below transition script (migrate_solr_to_elasticsearch) and paste it to the bin/ directory of your PoolParty installation.

      #!/bin/bash
      
      DIR_SCRIPT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
      POOLPARTY_CONF="${DIR_SCRIPT}"/../config/poolparty.conf
      INSTALLER_PROPERTIES="${DIR_SCRIPT}"/../config/installer.properties
      DIR_ES="${DIR_SCRIPT}"/../index/elasticsearch
      
      # Start ES
      if [[ $EUID -eq 0 ]]; then
              run_as=$(ls -l "$DIR_SCRIPT/elasticsearch" | awk '{print $3}')
      	su - $run_as -c "$DIR_SCRIPT/elasticsearch start"
      else
      	$DIR_SCRIPT/elasticsearch start
      fi
      
      TIMEOUT=60
      INTERVAL=5
      ELAPSED=0
      
      # Check if Elasticsearch is listening on port 9200 using lsof
      while [ $ELAPSED -lt $TIMEOUT ]; do
          if lsof -i :9200 | grep -q LISTEN; then
              echo "Elasticsearch is up and running on port 9200."
              break
          else
              echo "Elasticsearch is not up yet. Retrying... (Elapsed: $ELAPSED seconds)"
          fi
      
          # Increment the elapsed time and wait for the next interval
          ELAPSED=$((ELAPSED + INTERVAL))
          sleep $INTERVAL
      done
      
      if [ $ELAPSED -ge $TIMEOUT ]; then
          echo "Elasticsearch did not start within the timeout period."
          exit 1
      fi
      
      
      # Reset the password for the elastic user and capture the output
      PASSWORD_OUTPUT=$(echo "y" | "${DIR_ES}"/bin/elasticsearch-reset-password -u elastic 2>/dev/null)
      
      # Extract the new password from the output using grep with Perl-compatible regular expressions
      PASSWORD_ES=$(echo "$PASSWORD_OUTPUT" | grep -oP 'New value: \K.*')
      
      cp "${POOLPARTY_CONF}" "${POOLPARTY_CONF}".bak
      sed -i 's/^builtin=true/builtin=false/' "${POOLPARTY_CONF}"
      sed -i 's/^ES_START=false/ES_START=true/' "${POOLPARTY_CONF}"
      
      
      # create installer.properties
      {
      	echo "index.type=ELASTICSEARCH"
      	echo "index.host=http://localhost:9200"
      	echo "index.username=elastic"
      	echo "index.password=${PASSWORD_ES}"
      } > "${INSTALLER_PROPERTIES}"
      
      
      echo "New ES password: ${PASSWORD_ES}"
  2. Execute this script

    1. Navigate to the bin directory and run the script by executing ./migrate_solr_to_elasticsearch

    2. This script performs several tasks:

      1. It starts the Elasticsearch service;

      2. It checks and confirms that Elasticsearch is listening on port 9200;

      3. It resets the password of the Elasticsearch user 'elastic';

      4. It modifies the poolparty.conf file to deactivate Solr and activate Elasticsearch;

      5. It creates a new installer.properties file with configuration settings for Elasticsearch.

    3. Script output

      • The script will provide a new password for the Elasticsearch user 'elastic'.

  3. Finalize transition to Elasticsearch

    1. Initial upstart: Start PoolParty. Initially, the status of the index may be shown in RED in the Semantic Middleware Configurator indicating that it has to be started again.

    2. Restart PoolParty: Restart PoolParty to complete the integration of Elasticsearch which will be reflected by showing the status of the index in GREEN.

Troubleshooting

  • If Elasticsearch fails to start, check for any potential port conflicts or permission issues.

  • Make sure that the poolparty.conf and installer.properties files contain the correct configuration changes.

Note

Please refer to Migrating Index from Solr to Elasticsearch on Linux for more details how you can migrate your Solr index to Elasticsearch.