Skip to content

Commit a133cea

Browse files
committed
Dedicated test fix
1 parent 0ef8fcd commit a133cea

File tree

4 files changed

+72
-11
lines changed

4 files changed

+72
-11
lines changed

.github/init_solr.sh

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ SOLR_VERSION=${SOLR_VERSION:-'9.8.1'}
66

77
if [[ "${SOLR_VERSION}" =~ ^9\. ]]; then
88
default_config_files[1]="${SCRIPT_DIR}/../src/lib/Resources/config/solr/managed-schema.xml"
9+
default_config_files[2]="${SCRIPT_DIR}/../src/lib/Resources/config/solr/custom-fields-types-solr9.xml"
910
else
1011
default_config_files[1]="${SCRIPT_DIR}/../src/lib/Resources/config/solr/schema.xml"
12+
default_config_files[2]="${SCRIPT_DIR}/../src/lib/Resources/config/solr/custom-fields-types.xml"
1113
fi
1214

13-
default_config_files[2]="${SCRIPT_DIR}/../src/lib/Resources/config/solr/custom-fields-types.xml"
1415
default_config_files[3]="${SCRIPT_DIR}/../src/lib/Resources/config/solr/language-fieldtypes.xml"
1516

1617
default_cores[0]='core0'
@@ -154,7 +155,11 @@ solr_run() {
154155
echo "Running with version ${SOLR_VERSION} in standalone mode"
155156
echo "Starting solr on port ${SOLR_PORT}..."
156157

157-
./${SOLR_INSTALL_DIR}/bin/solr start --host 0.0.0.0 -p ${SOLR_PORT} -s ${SOLR_HOME} -Dsolr.jetty.host=0.0.0.0 -Dsolr.disable.allowUrls=true -Dsolr.disable.shardsWhitelist=true || exit_on_error "Can't start Solr"
158+
if [[ "${SOLR_VERSION}" =~ ^9\. ]]; then
159+
./${SOLR_INSTALL_DIR}/bin/solr start -p ${SOLR_PORT} -s ${SOLR_HOME} || exit_on_error "Can't start Solr"
160+
else
161+
./${SOLR_INSTALL_DIR}/bin/solr -p ${SOLR_PORT} -s ${SOLR_HOME} -Dsolr.disable.shardsWhitelist=true || exit_on_error "Can't start Solr"
162+
fi
158163

159164
echo "Started"
160165

@@ -179,11 +184,7 @@ solr_create_core() {
179184
core_name=$1
180185
config_dir=$2
181186

182-
if [[ "$SOLR_VERSION" =~ ^9\. ]]; then
183-
solr_port_flag="--solr-url http://localhost:${SOLR_PORT}/solr"
184-
else
185-
solr_port_flag="-p ${SOLR_PORT}"
186-
fi
187+
solr_port_flag="-p ${SOLR_PORT}"
187188

188189
abs_conf_dir="$(pwd)/${config_dir}"
189190

@@ -316,6 +317,20 @@ if [ "$SOLR_CLOUD" = "no" ]; then
316317
TEMPLATE_CONF="template"
317318
fi
318319

320+
echo "Generating Solr configuration in ${SOLR_INSTALL_DIR}/server/${SOLR_HOME}/${TEMPLATE_CONF}"
321+
322+
if [[ "${CORES_SETUP:-}" == "dedicated" || "${SOLR_CLOUD:-}" == "no" ]]; then
323+
# dedicated mode: point at the local core path
324+
ALLOW_URLS="localhost:${SOLR_PORT}/solr"
325+
elif [[ "${SOLR_CLOUD:-}" == "yes" && ${#default_nodes[@]} -gt 0 ]]; then
326+
# SolrCloud mode: join all nodes host:port
327+
ALLOW_URLS=$(IFS=,; echo "${default_nodes[*]}")
328+
else
329+
# fallback: single node without core-path
330+
ALLOW_URLS="localhost:${SOLR_PORT}"
331+
fi
332+
export ALLOW_URLS
333+
319334
$SCRIPT_DIR/../bin/generate-solr-config.sh \
320335
--solr-install-dir="${SOLR_INSTALL_DIR}" \
321336
--solr-version="${SOLR_VERSION}" \

bin/generate-solr-config.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ DESTINATION_DIR=.platform/configsets/solr8/conf
77
SOLR_VERSION=8.11.1
88
FORCE=false
99
SOLR_INSTALL_DIR=""
10+
ALLOW_URLS_CLI=""
1011

1112
show_help() {
1213
cat << EOF
@@ -65,6 +66,9 @@ for i in "$@"; do
6566
SOLR_INSTALL_DIR="${i#*=}"
6667
SOLR_INSTALL_DIR="${SOLR_INSTALL_DIR/#\~/$HOME}"
6768
;;
69+
--allow-urls)
70+
ALLOW_URLS_CLI="$2"; shift 2
71+
;;
6872
-h|--help)
6973
show_help
7074
exit 0
@@ -76,6 +80,7 @@ for i in "$@"; do
7680
esac
7781
done
7882

83+
: "${ALLOW_URLS_CLI:=${ALLOW_URLS:-}}"
7984

8085
if [ `whoami` == "root" ]; then
8186
echo "Error : Do not run this script as root"
@@ -112,8 +117,30 @@ cp -a ${EZ_BUNDLE_PATH}/src/lib/Resources/config/solr/* $DESTINATION_DIR
112117
cp ${SOLR_INSTALL_DIR}/server/solr/configsets/_default/conf/{solrconfig.xml,stopwords.txt,synonyms.txt} $DESTINATION_DIR
113118

114119
if [[ ! $DESTINATION_DIR =~ ^\.platform ]]; then
115-
# If we are not targeting .platform(.sh) config, we also output default solr.xml
116-
cp -f ${SOLR_INSTALL_DIR}/server/solr/solr.xml $DESTINATION_DIR/..
120+
121+
if [[ "${SOLR_VERSION}" =~ ^9\. ]]; then
122+
cp -f ${SOLR_INSTALL_DIR}/server/solr/solr.xml $DESTINATION_DIR/../..
123+
124+
URL_LIST="${ALLOW_URLS_CLI//,/ }"
125+
SOLR_XML_PATH="${DESTINATION_DIR}/../../solr.xml"
126+
127+
if [[ -f "$SOLR_XML_PATH" ]]; then
128+
# backup original
129+
cp "$SOLR_XML_PATH" "${SOLR_XML_PATH}.bak"
130+
# replace inner text of the allowUrls element
131+
sed -i \
132+
-e "s|\(<str name=\"allowUrls\">\)[^<]*\(<\/str>\)|\1${URL_LIST}\2|" \
133+
"$SOLR_XML_PATH"
134+
echo "NOTE: Updated <str name=\"allowUrls\"> to: ${URL_LIST}"
135+
else
136+
echo "WARNING: solr.xml not found at '$SOLR_XML_PATH'; skipping allowUrls patch"
137+
fi
138+
else
139+
# If we are not targeting .platform(.sh) config, we also output default solr.xml
140+
echo "Copying ${SOLR_INSTALL_DIR}/server/solr/solr.xml to $DESTINATION_DIR/.."
141+
142+
cp -f ${SOLR_INSTALL_DIR}/server/solr/solr.xml $DESTINATION_DIR/..
143+
fi
117144
else
118145
echo "NOTE: Skipped copying ${SOLR_INSTALL_DIR}/server/solr/solr.xml given destination dir is a '.platform/' config folder"
119146
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
This is additional custom example fields. You can come up with similar
3+
fields on your own, if you require custom indexing / query rules.
4+
5+
Instead of using the type "text" you might even want to define a custom
6+
type. In the custom type you can define your dedicated index and query
7+
rules. You can copy any existing fields into the custom field as seen
8+
below.
9+
10+
In this case we copy the full user name and index it as a text field.
11+
-->
12+
<field name="custom_field" type="text" indexed="true" stored="false" required="false" multiValued="true" />
13+
<copyField source="user_first_name_value_s" dest="custom_field" />
14+
<copyField source="user_last_name_value_s" dest="custom_field" />
15+
16+
<field name="custom_geolocation_field" type="location" indexed="true" stored="false" required="false" />
17+
18+
<copyField source="testtype_maplocation_value_location_gl" dest="custom_geolocation_field" />

src/lib/Resources/config/solr/custom-fields-types.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<copyField source="user_first_name_value_s" dest="custom_field" />
1414
<copyField source="user_last_name_value_s" dest="custom_field" />
1515

16-
<field name="custom_geolocation_field" type="location" indexed="true" stored="false" docValues="true" required="false" />
17-
16+
<field name="custom_geolocation_field" type="location" indexed="true" stored="false" required="false" />
17+
<field name="custom_geolocation_field_0_coordinate" type="double" indexed="true" stored="false"/>
18+
<field name="custom_geolocation_field_1_coordinate" type="double" indexed="true" stored="false"/>
1819
<copyField source="testtype_maplocation_value_location_gl" dest="custom_geolocation_field" />

0 commit comments

Comments
 (0)