Published in: Bash
A convenient wrapper around curl to provide a command-line interface to Apache Solr.
It depends on curl to carry out the commands, xmllint to pretty-print the XML result, and Pygments to syntax-highlight the XML result.
Usage: solr BASE RESOURCE <ARGS>
BASEis either the http:// base of a solr instance, or one of the known shortcuts in the case statement.RESOURCEmakes$BASE/$RESOURCEthe full REST URL.ARGSare are passed to curl. Use -F key=value to POST form parameters.
Examples:
solr http://localhost:8983/solr admin/cores -F command=RELOAD -F core=core0
solr local admin/cores -F command=RELOAD -F core=core0
solr local dataimport -F command=delta-import
solr local core0/select?q=solr
solr example trunk/update -d '<delete><id>1</id></delete>'
Expand |
Embed | Plain Text
#!/bin/bash BASE="$1"; shift RESOURCE="$1"; shift case $BASE in example) URL=http://www.example.com:8983/solr ;; local) URL=http://localhost:8983/solr ;; http*) URL="$BASE" ;; esac [ -z $URL ] && { echo "No base URL specified."; exit 1; } [ -z $RESOURCE ] && { echo "No resource specified."; exit 1; } curl -s -H "Content-Type: text/xml" "$URL/$RESOURCE" "$@" | xmllint --format - | pygmentize -l xml -f console
You need to login to post a comment.
