forked from ymaurer/cdx-summarize-warc-indexer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
execute_solr_queries.sh
executable file
·37 lines (31 loc) · 1.02 KB
/
execute_solr_queries.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
if [ "$1" == "--help" ]; then
echo "usage: execute_solr_queries.sh [queryfile]"
echo " without arguments it runs all .q files in the current directoty"
echo " queryfile : a single json formatted query file to run"
exit
fi
pushd ${BASH_SOURCE%/*} > /dev/null
if [[ -s "solr.conf" ]]; then
source "solr.conf" # Optional config
fi
popd > /dev/null
: ${SERVER:="localhost"}
: ${PORT:="8983"}
: ${INDEX:="netarchivebuilder"}
: ${URL:="http://${SERVER}:${PORT}/solr/${INDEX}/query"}
: ${JQFILTER:=".facets.domains.buckets[] | {\"domain\":.val,\"years\":.years[][]}"}
: ${JQCSV:="[.domain, .years.val,.years.count,.years.sizes] | @csv"}
: ${CURL:="curl -s"}
if [ $# -gt 0 ]; then
echo "${CURL} \"${URL}\" -d @${1} | jq \"${JQFILTER}\" | jq -r \"${JQCSV}\""
# ${CURL} "${URL}" -d @${1} | jq "${JQFILTER}" | jq -r "${JQCSV}"
exit
fi
for f in *.q
do
OUTF="${f:6:${#f}-8}-result.csv"
D=`date -Is`
echo "$D - running ${f} into ${OUTF}"
${CURL} "${URL}" -d @${f} | jq "${JQFILTER}" | jq -r "${JQCSV}" > "${OUTF}"
done