From f00e0c1656daf25c0147d98beb100beda43c709a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Wed, 17 Apr 2019 22:33:05 +0200 Subject: [PATCH] EZP-30835: Added support for Solr 7.7 --- .travis.yml | 15 +++--- bin/.travis/init_solr.sh | 21 ++++---- bin/generate-solr-config.sh | 12 ++--- .../QueryConverter/NativeQueryConverter.php | 1 - lib/Resources/config/solr/schema.xml | 53 ++++++++++++++----- 5 files changed, 66 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31c7924ca..0c53ebee1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,13 +13,14 @@ matrix: - php: 7.2 env: TEST_CONFIG="phpunit.xml" - php: 7.1 - env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="6.4.2" CORES_SETUP="dedicated" - - php: 7.2 - env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="6.5.1" CORES_SETUP="shared" - - php: 7.2 - env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="6.6.5" CORES_SETUP="single" SOLR_CORES="collection1" - - php: 7.2 - env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="6.6.5" CORES_SETUP="cloud" SOLR_CLOUD="yes" + env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="7.7.2" CORES_SETUP="dedicated" + - php: 7.1 + env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="7.7.2" CORES_SETUP="shared" + - php: 7.1 + env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="7.7.2" CORES_SETUP="single" SOLR_CORES="collection1" + - php: 7.1 + env: TEST_CONFIG="phpunit-integration-legacy-solr.xml" SOLR_VERSION="7.7.2" CORES_SETUP="cloud" SOLR_CLOUD="yes" + # test only master and stable branches (+ Pull requests against those) branches: only: diff --git a/bin/.travis/init_solr.sh b/bin/.travis/init_solr.sh index 0b7486be5..f0bdcd197 100755 --- a/bin/.travis/init_solr.sh +++ b/bin/.travis/init_solr.sh @@ -15,7 +15,7 @@ default_shards=('shard0') SOLR_PORT=${SOLR_PORT:-8983} SOLR_DIR=${SOLR_DIR:-'__solr'} -SOLR_VERSION=${SOLR_VERSION:-'6.6.5'} +SOLR_VERSION=${SOLR_VERSION:-'7.7.2'} SOLR_INSTALL_DIR="${SOLR_DIR}/${SOLR_VERSION}" SOLR_DEBUG=${SOLR_DEBUG:-false} SOLR_HOME=${SOLR_HOME:-'ezcloud'} @@ -44,7 +44,7 @@ fi download() { case ${SOLR_VERSION} in # PS!!: Append versions and don't remove old once, kernel uses this script! - 6.3.0|6.4.1|6.4.2|6.5.1|6.6.0|6.6.5 ) + 7.7.2 ) url="http://archive.apache.org/dist/lucene/solr/${SOLR_VERSION}/solr-${SOLR_VERSION}.tgz" ;; *) @@ -131,19 +131,19 @@ wait_for_solr(){ done } -# Run for Solr 6 +# Run for Solr 7 solr_run() { echo "Running with version ${SOLR_VERSION} in standalone mode" echo "Starting solr on port ${SOLR_PORT}..." - ./${SOLR_INSTALL_DIR}/bin/solr -p ${SOLR_PORT} -s ${SOLR_HOME} || exit_on_error "Can't start Solr" + ./${SOLR_INSTALL_DIR}/bin/solr -p ${SOLR_PORT} -s ${SOLR_HOME} -Dsolr.disable.shardsWhitelist=true || exit_on_error "Can't start Solr" echo "Started" solr_create_cores } -# Create cores for Solr 6 +# Create cores for Solr 7 solr_create_cores() { home_dir="${SOLR_INSTALL_DIR}/server/${SOLR_HOME}" template_dir="${home_dir}/template" @@ -218,18 +218,18 @@ solr_cloud_configure_collection() { create_dir ${TEMPLATE_DIR} local files=("${SOLR_CONFIG[@]}") - local config_dir="${INSTALL_DIR}/server/solr/configsets/basic_configs/conf" + local config_dir="${INSTALL_DIR}/server/solr/configsets/_default/conf" - files+=("${config_dir}/currency.xml") + echo $config_dir; + + files+=("${config_dir}/solrconfig.xml") files+=("${config_dir}/stopwords.txt") files+=("${config_dir}/synonyms.txt") - files+=("${config_dir}/elevate.xml") - files+=("${config_dir}/solrconfig.xml") copy_files ${TEMPLATE_DIR} "${files[*]}" # modify solrconfig.xml to remove section that doesn't agree with our schema - sed -i.bak '//,/<\/updateRequestProcessorChain>/d' "${TEMPLATE_DIR}/solrconfig.xml" || exit_on_error "Can't modify file '${TEMPLATE_DIR}/solrconfig.xml'" + sed -i.bak '//d' ${TEMPLATE_DIR}/solrconfig.xml # Adapt autoSoftCommit to have a recommended value sed -i.bak2 's/${solr.autoSoftCommit.maxTime:-1}/${solr.autoSoftCommit.maxTime:20}/' "${TEMPLATE_DIR}/solrconfig.xml" || exit_on_error "Can't modify file '${TEMPLATE_DIR}/solrconfig.xml'" } @@ -281,6 +281,7 @@ download if [ "$SOLR_CLOUD" = "no" ]; then $SCRIPT_DIR/../generate-solr-config.sh \ --solr-install-dir="${SOLR_INSTALL_DIR}" \ + --solr-version="${SOLR_VERSION}" \ --destination-dir="${SOLR_INSTALL_DIR}/server/${SOLR_HOME}/template" solr_run else diff --git a/bin/generate-solr-config.sh b/bin/generate-solr-config.sh index edbf7c8b2..34f913865 100755 --- a/bin/generate-solr-config.sh +++ b/bin/generate-solr-config.sh @@ -4,7 +4,7 @@ set -e # Default paramters, if not overloaded by user arguments DESTINATION_DIR=.platform/configsets/solr6/conf -SOLR_VERSION=6.6.5 +SOLR_VERSION=7.7.2 FORCE=false SOLR_INSTALL_DIR="" @@ -20,7 +20,7 @@ Help (this text): Usage with eZ Platform Cloud (arguments here can be skipped as they have default values): ./vendor/ezsystems/ezplatform-solr-search-engine/bin/generate-solr-config.sh \\ --destination-dir=.platform/configsets/solr6/conf \\ - --solr-version=6.6.5 + --solr-version=7.7.2 Usage with on-premise version of Solr: ./vendor/ezsystems/ezplatform-solr-search-engine/bin/generate-solr-config.sh \\ @@ -28,7 +28,7 @@ Usage with on-premise version of Solr: --solr-install-dir=/opt/solr Warning: - This script only supports Solr 6 and higher !! + This script only supports Solr 7 and higher !! Arguments: @@ -94,7 +94,7 @@ if [ -e $DESTINATION_DIR ]; then fi if [ "$SOLR_INSTALL_DIR" == "" ]; then - # If we where not provided existing install directory we'll temporary download version of solr 6 to generate config. + # If we where not provided existing install directory we'll temporary download version of solr 7 to generate config. GENERATE_SOLR_TMPDIR=`mktemp -d` echo "Downloading solr bundle:" curl http://archive.apache.org/dist/lucene/solr/${SOLR_VERSION}/solr-${SOLR_VERSION}.tgz > $GENERATE_SOLR_TMPDIR/solr-${SOLR_VERSION}.tgz @@ -109,7 +109,7 @@ fi mkdir -p $DESTINATION_DIR cp -a ${EZ_BUNDLE_PATH}/lib/Resources/config/solr/* $DESTINATION_DIR -cp ${SOLR_INSTALL_DIR}/server/solr/configsets/basic_configs/conf/{currency.xml,solrconfig.xml,stopwords.txt,synonyms.txt,elevate.xml} $DESTINATION_DIR +cp ${SOLR_INSTALL_DIR}/server/solr/configsets/_default/conf/{solrconfig.xml,stopwords.txt,synonyms.txt} $DESTINATION_DIR if [[ ! $DESTINATION_DIR =~ ^\.platform ]]; then # If we are not targeting .platform(.sh) config, we also output default solr.xml @@ -119,7 +119,7 @@ else fi # Adapt autoSoftCommit to have a recommended value, and remove add-unknown-fields-to-the-schema -sed -i.bak '//,/<\/updateRequestProcessorChain>/d' $DESTINATION_DIR/solrconfig.xml +sed -i.bak '//d' $DESTINATION_DIR/solrconfig.xml sed -i.bak2 's/${solr.autoSoftCommit.maxTime:-1}/${solr.autoSoftCommit.maxTime:20}/' $DESTINATION_DIR/solrconfig.xml if [ "$GENERATE_SOLR_TMPDIR" != "" ]; then diff --git a/lib/Query/Common/QueryConverter/NativeQueryConverter.php b/lib/Query/Common/QueryConverter/NativeQueryConverter.php index 3f1908042..69c567584 100644 --- a/lib/Query/Common/QueryConverter/NativeQueryConverter.php +++ b/lib/Query/Common/QueryConverter/NativeQueryConverter.php @@ -62,7 +62,6 @@ public function __construct( public function convert(Query $query) { $params = array( - 'defType' => 'edismax', 'q' => '{!lucene}' . $this->criterionVisitor->visit($query->query), 'fq' => '{!lucene}' . $this->criterionVisitor->visit($query->filter), 'sort' => $this->getSortClauses($query->sortClauses), diff --git a/lib/Resources/config/solr/schema.xml b/lib/Resources/config/solr/schema.xml index 4730200dc..361630025 100644 --- a/lib/Resources/config/solr/schema.xml +++ b/lib/Resources/config/solr/schema.xml @@ -41,24 +41,49 @@ should not remove or drastically change the existing definitions. + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - - - + + + + + - - - - - @@ -101,7 +126,11 @@ should not remove or drastically change the existing definitions. - + + +