Skip to content

Commit

Permalink
EZP-30835: Added support for Solr 7.7
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs committed Oct 4, 2019
1 parent 1e22193 commit f00e0c1
Showing 5 changed files with 66 additions and 36 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
21 changes: 11 additions & 10 deletions bin/.travis/init_solr.sh
Original file line number Diff line number Diff line change
@@ -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 name="add-unknown-fields-to-the-schema">/,/<\/updateRequestProcessorChain>/d' "${TEMPLATE_DIR}/solrconfig.xml" || exit_on_error "Can't modify file '${TEMPLATE_DIR}/solrconfig.xml'"
sed -i.bak '/<updateRequestProcessorChain name="add-unknown-fields-to-the-schema".*/,/<\/updateRequestProcessorChain>/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
12 changes: 6 additions & 6 deletions bin/generate-solr-config.sh
Original file line number Diff line number Diff line change
@@ -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,15 +20,15 @@ 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 \\
--destination-dir=/opt/solr/server/ez/template \\
--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 name="add-unknown-fields-to-the-schema">/,/<\/updateRequestProcessorChain>/d' $DESTINATION_DIR/solrconfig.xml
sed -i.bak '/<updateRequestProcessorChain name="add-unknown-fields-to-the-schema".*/,/<\/updateRequestProcessorChain>/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
1 change: 0 additions & 1 deletion lib/Query/Common/QueryConverter/NativeQueryConverter.php
Original file line number Diff line number Diff line change
@@ -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),
53 changes: 41 additions & 12 deletions lib/Resources/config/solr/schema.xml
Original file line number Diff line number Diff line change
@@ -41,24 +41,49 @@ should not remove or drastically change the existing definitions.
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100" multiValued="true" sortMissingLast="true">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

<fieldType name="pdate" class="solr.DatePointField" docValues="true"/>
<fieldType name="pdates" class="solr.DatePointField" docValues="true" multiValued="true"/>
<!--
Numeric field types that index values using KD-trees.
Point fields don't support FieldCache, so they must have docValues="true" if needed for sorting, faceting, functions, etc.
-->
<fieldType name="pint" class="solr.IntPointField" docValues="true"/>
<fieldType name="pfloat" class="solr.FloatPointField" docValues="true"/>
<fieldType name="plong" class="solr.LongPointField" docValues="true"/>
<fieldType name="pdouble" class="solr.DoublePointField" docValues="true"/>

<fieldType name="pints" class="solr.IntPointField" docValues="true" multiValued="true"/>
<fieldType name="pfloats" class="solr.FloatPointField" docValues="true" multiValued="true"/>
<fieldType name="plongs" class="solr.LongPointField" docValues="true" multiValued="true"/>
<fieldType name="pdoubles" class="solr.DoublePointField" docValues="true" multiValued="true"/>
<fieldType name="random" class="solr.RandomSortField" indexed="true"/>

<fieldType name="identifier" class="solr.StrField" sortMissingLast="true" />
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" multiValued="false"/>
<fieldType name="booleans" class="solr.BoolField" sortMissingLast="true" multiValued="true"/>
<fieldtype name="binary" class="solr.BinaryField"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
<fieldType name="int" class="solr.IntPointField" docValues="true"/>
<fieldType name="float" class="solr.FloatPointField" docValues="true"/>
<fieldType name="long" class="solr.LongPointField" docValues="true"/>
<fieldType name="double" class="solr.DoublePointField" docValues="true"/>
<fieldType name="date" class="solr.DatePointField" docValues="true"/>

<fieldtype name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField" />
<fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>

<fieldType name="currency" class="solr.CurrencyField" precisionStep="8" defaultCurrency="USD" currencyConfig="currency.xml" />




<!--
Required ID field.
-->
@@ -101,7 +126,11 @@ should not remove or drastically change the existing definitions.
<dynamicField name="*_gl" type="location" indexed="true" stored="true"/>
<dynamicField name="*_gl_0_coordinate" type="double" indexed="true" stored="true"/>
<dynamicField name="*_gl_1_coordinate" type="double" indexed="true" stored="true"/>
<dynamicField name="*_c" type="currency" indexed="true" stored="true"/>

<!--
This field is required to allow random sorting
-->
<dynamicField name="random*" type="random" indexed="true" stored="false"/>

<!--
This field is required since Solr 4

0 comments on commit f00e0c1

Please # to comment.