-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsolrQuery.sh
More file actions
executable file
·70 lines (60 loc) · 1.66 KB
/
solrQuery.sh
File metadata and controls
executable file
·70 lines (60 loc) · 1.66 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
###############################################################################
## Runs a Solr Query
## W 16 Nov 2016
###############################################################################
printHelp() {
echo "solrQuery.sh <option(s)>"
echo ""
echo "options include"
echo -e "\t-h\tprint this help info"
echo -e "\t-p\tthe port Solr runs on (defaults to 8983)"
echo -e "\t-c\tthe Solr collection to query [MANDATORY]"
echo -e "\t-q\tthe Solr query (e.g. \"select\") [MANDATORY]"
echo -e "\t-a\tthe arguments to the Solr query (e.g. \"q=*%3A*\") [MANDATORY]"
echo -
echo ""
return 0
}
SOLR_PORT=8983
# Doesn't change
SOLR_CONTEXT=solr
while getopts ":hc:p:q:a:" opt; do
case $opt in
h)
printHelp
exit 0
;;
c)
SOLR_COLLECTION=${OPTARG}
;;
p)
SOLR_PORT=${OPTARG}
;;
q)
SOLR_QUERY=${OPTARG}
;;
a)
SOLR_ARGS=${OPTARG}
;;
?)
printHelp
exit 0
;;
esac
done
if [[ -z ${SOLR_COLLECTION} ]];then
echo "[ERROR] Must specify a Solr Collection to query with -c option"
exit 0
fi
if [[ -z ${SOLR_QUERY} ]];then
echo "[ERROR] Must specify a Solr Query (e.g. \"select\") with -q option"
exit 0
fi
if [[ -z ${SOLR_ARGS} ]];then
echo "[ERROR] Must specificy the arguments to the Solr Query (e.g. \"q=*%3A*\") with the -a option"
exit 0
fi
CMD="curl -X GET 'http://${KNOX_HDP}:${SOLR_PORT}/${SOLR_CONTEXT}/${SOLR_COLLECTION}/${SOLR_QUERY}?${SOLR_ARGS}&wt=json&indent=true'"
echo ${CMD}
eval ${CMD}