forked from querqy/chorus-elasticsearch-edition
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial SMUI integration. Coverage: Python + shell scripts to push ru…
…les to Elasticsearch. Keycloak fixes for local Apple M1 development. See docker/for-mac#5310 (comment) for additional information
- Loading branch information
1 parent
1e142c3
commit 00be82f
Showing
9 changed files
with
208 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM querqy/smui:3.14 | ||
|
||
COPY conf/smui2es.sh /smui/conf/smui2es.sh | ||
COPY conf/*.py /smui/conf/ | ||
COPY conf/predefined_tags.json /smui/conf/predefined_tags.json | ||
|
||
USER root | ||
RUN apt-get update -y | ||
RUN apt-get install -y python3 | ||
RUN apt-get install -y python3-pip | ||
RUN chown -R smui:smui /smui/conf | ||
USER smui | ||
RUN python3 -m pip install requests |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[ | ||
{ | ||
"property": "tenant", | ||
"value": "MO" | ||
}, | ||
{ | ||
"property": "tenant", | ||
"value": "HA" | ||
}, | ||
{ | ||
"solrIndexName": "de", | ||
"property": "tenant", | ||
"value": "MO_DE" | ||
}, | ||
{ | ||
"solrIndexName": "de", | ||
"property": "tenant", | ||
"value": "MO_AT" | ||
}, | ||
{ | ||
"solrIndexName": "de", | ||
"property": "tenant", | ||
"value": "MO_CH" | ||
}, | ||
{ | ||
"solrIndexName": "fr", | ||
"property": "tenant", | ||
"value": "MO_CH" | ||
}, | ||
{ | ||
"solrIndexName": "fr", | ||
"property": "tenant", | ||
"value": "MO_FR" | ||
}, | ||
{ | ||
"solrIndexName": "fr", | ||
"property": "tenant", | ||
"value": "MO_BE" | ||
}, | ||
{ | ||
"value": "zero results", | ||
"exported": false | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sys,json,requests | ||
|
||
if __name__ == "__main__": | ||
|
||
if len(sys.argv) != 3: | ||
print('Usage: push_common_rules.py <rules.txt> <http://<elasticsearch_host:port>/_querqy/rewriter/<rewriter_name>') | ||
sys.exit(1) | ||
|
||
rules_file = sys.argv[1] | ||
rewriter_url = sys.argv[2] | ||
|
||
f = open(rules_file, "r") | ||
|
||
req = { | ||
"class": "querqy.elasticsearch.rewriter.SimpleCommonRulesRewriterFactory", | ||
"config": { | ||
"rules" : f.read() | ||
} | ||
} | ||
|
||
resp = requests.put(rewriter_url, json=req) | ||
if resp.status_code != 200: | ||
sys.exit(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import sys,json,requests | ||
|
||
if __name__ == "__main__": | ||
|
||
if len(sys.argv) != 3: | ||
print('Usage: push_replace.py <rules.txt> <http://<elasticsearch_host:port>/_querqy/rewriter/<rewriter_name>') | ||
sys.exit(1) | ||
|
||
rules_file = sys.argv[1] | ||
rewriter_url = sys.argv[2] | ||
|
||
f = open(rules_file, "r") | ||
|
||
req = { | ||
"class": "querqy.elasticsearch.rewriter.ReplaceRewriterFactory", | ||
"config": { | ||
"rules": f.read(), | ||
"ignoreCase": True, | ||
"inputDelimiter": ";", | ||
"querqyParser": "querqy.rewrite.commonrules.WhiteSpaceQuerqyParserFactory" | ||
} | ||
} | ||
|
||
resp = requests.put(rewriter_url, json=req) | ||
if resp.status_code != 200: | ||
sys.exit(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
SRC_TMP_FILE=$1 | ||
DST_CP_FILE_TO=$2 | ||
ES_HOST=$3 | ||
SOLR_CORE_NAME=$4 | ||
DECOMPOUND_DST_CP_FILE_TO=$5 | ||
TARGET_SYSTEM=$6 | ||
REPLACE_RULES_SRC_TMP_FILE=$7 | ||
REPLACE_RULES_DST_CP_FILE_TO=$8 | ||
|
||
echo "In smui2es.sh - script deploying rules to Elasticsearch for Querqy" | ||
echo "^-- SRC_TMP_FILE = $SRC_TMP_FILE" | ||
echo "^-- DST_CP_FILE_TO = $DST_CP_FILE_TO" | ||
echo "^-- ES_HOST = $ES_HOST" | ||
echo "^-- SOLR_CORE_NAME = $SOLR_CORE_NAME" | ||
echo "^-- DECOMPOUND_DST_CP_FILE_TO = $DECOMPOUND_DST_CP_FILE_TO" | ||
echo "^-- TARGET_SYSTEM = $TARGET_SYSTEM" | ||
echo "^-- REPLACE_RULES_SRC_TMP_FILE = $REPLACE_RULES_SRC_TMP_FILE" | ||
echo "^-- REPLACE_RULES_DST_CP_FILE_TO = $REPLACE_RULES_DST_CP_FILE_TO" | ||
|
||
# DEPLOYMENT | ||
##### | ||
|
||
echo "^-- Perform rules.txt deployment (decompound-rules.txt eventually)" | ||
|
||
function common_rules_rewriter_url() { | ||
if [ $TARGET_SYSTEM == "LIVE" ]; then | ||
URL="http://$ES_HOST/_querqy/rewriter/common_rules" | ||
else | ||
URL="http://$ES_HOST/_querqy/rewriter/common_rules_prelive" | ||
fi | ||
} | ||
function replace_rewriter_url() { | ||
if [ $TARGET_SYSTEM == "LIVE" ]; then | ||
URL="http://$ES_HOST/_querqy/rewriter/replace" | ||
else | ||
URL="http://$ES_HOST/_querqy/rewriter/replace_prelive" | ||
fi | ||
} | ||
|
||
echo "^-- ... rules.txt" | ||
common_rules_rewriter_url $1 | ||
|
||
python3 /smui/conf/push_common_rules.py $SRC_TMP_FILE $URL | ||
if [ $? -ne 0 ]; then | ||
exit 16 | ||
fi | ||
|
||
echo "^-- ... replace-rules.txt" | ||
replace_rewriter_url $1 | ||
if ! [[ $REPLACE_RULES_SRC_TMP_FILE == "NONE" && $REPLACE_RULES_DST_CP_FILE_TO == "NONE" ]] | ||
then | ||
python3 /smui/conf/push_replace.py $REPLACE_RULES_SRC_TMP_FILE $URL | ||
fi | ||
|
||
# all ok | ||
echo "smui2es.sh - ok" | ||
exit 0 |