diff --git a/solr/bin/post b/solr/bin/post index 42979fa751e..d6b7f55fb7c 100755 --- a/solr/bin/post +++ b/solr/bin/post @@ -70,22 +70,22 @@ function print_usage() { echo "OPTIONS" echo "=======" echo " Solr options:" - echo " url= (overrides collection, host, and port)" - echo " host= (default: localhost)" - echo " port= (default: 8983)" - echo " commit=yes|no (default: yes)" + echo " -url (overrides collection, host, and port)" + echo " -host (default: localhost)" + echo " -port (default: 8983)" + echo " -commit yes|no (default: yes)" echo "" echo " Web crawl options:" - echo " recursive= (default: 1)" - echo " delay= (default=10)" + echo " -recursive (default: 1)" + echo " -delay (default=10)" echo "" echo " Directory crawl options:" - echo " delay= (default=0)" + echo " -delay (default=0)" echo "" echo " Other options:" - echo " filetypes=[,,...] (default: xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log)" - echo " params=\"=[&=...]\" (values must be URL-encoded)" - echo " out=yes|no (default=no; yes outputs Solr response to console)" + echo " -filetypes [,,...] (default: xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log)" + echo " -params \"=[&=...]\" (values must be URL-encoded; these pass through to Solr update request)" + echo " -out yes|no (default=no; yes outputs Solr response to console)" echo "" echo "" echo "Examples:" @@ -94,7 +94,7 @@ function print_usage() { echo "XML files: $THIS_SCRIPT -c records article*.xml" echo "CSV file: $THIS_SCRIPT -c signals LATEST-signals.csv" echo "Directory of files: $THIS_SCRIPT -c myfiles ~/Documents" - echo "Web crawl: $THIS_SCRIPT -c gettingstarted http://lucidworks.com recursive=2 delay=1" + echo "Web crawl: $THIS_SCRIPT -c gettingstarted http://lucidworks.com -recursive 2 -delay 1" echo "" } # end print_usage @@ -113,32 +113,38 @@ URLS=() while [ $# -gt 0 ]; do # TODO: natively handle the optional parameters to SPT # but for now they can be specified as bin/post -c collection-name delay=5 http://lucidworks.com - if [[ "$1" == "-c" ]]; then - # Pull out collection name - shift - COLLECTION=$1 + + if [[ -d "$1" ]]; then + # Directory +# echo "$1: DIRECTORY" + MODE="files" + RECURSIVE="-Drecursive=yes" + FILES+=("$1") + elif [[ -f "$1" ]]; then + # File +# echo "$1: FILE" + MODE="files" + FILES+=("$1") + elif [[ "$1" == http* ]]; then + # URL +# echo "$1: URL" + MODE="web" + URLS+=("$1") else - # General argument, either a file, directory, URL, or param[=val] - if [[ -d "$1" ]]; then - # Directory -# echo "$1: DIRECTORY" - MODE="files" - RECURSIVE="-Drecursive=yes" - FILES+=("$1") - elif [[ -f "$1" ]]; then - # File -# echo "$1: FILE" - MODE="files" - FILES+=("$1") - elif [[ "$1" == http* ]]; then - # URL -# echo "$1: URL" - MODE="web" - URLS+=("$1") + if [[ $1 == -* ]]; then + if [[ $1 == "-c" ]]; then + # Special case, pull out collection name + shift + COLLECTION=$1 + else + key=${1:1} + shift +# echo "$1: PROP" + PROPS="$PROPS -D$key=$1" + fi else - # Not a file, directory or URL. Consider it a property to SPT -# echo "$1: PROP" - PROPS="$PROPS -D$1" + echo -e "\nUnrecognized argument: $1\n" + exit 1 fi fi shift diff --git a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java b/solr/core/src/java/org/apache/solr/util/SimplePostTool.java index d119916dffa..d9879eac3af 100644 --- a/solr/core/src/java/org/apache/solr/util/SimplePostTool.java +++ b/solr/core/src/java/org/apache/solr/util/SimplePostTool.java @@ -76,7 +76,7 @@ import java.util.zip.InflaterInputStream; public class SimplePostTool { private static final String DEFAULT_POST_HOST = "localhost"; private static final String DEFAULT_POST_PORT = "8983"; - private static final String VERSION_OF_THIS_TOOL = "1.5"; + private static final String VERSION_OF_THIS_TOOL = "5.0.0"; // TODO: hardcoded for now, but eventually to sync with actual Solr version private static final String DEFAULT_COMMIT = "yes"; private static final String DEFAULT_OPTIMIZE = "no"; diff --git a/solr/example/README.txt b/solr/example/README.txt index 26f3b67c4f2..abea8ee8575 100644 --- a/solr/example/README.txt +++ b/solr/example/README.txt @@ -40,7 +40,7 @@ After starting a Solr example, direct your Web browser to: To add documents to the index, use bin/post, for example: - bin/post techproducts example/exampledocs/*.xml + bin/post -c techproducts example/exampledocs/*.xml (where "techproducts" is the Solr core name) diff --git a/solr/example/films/README.txt b/solr/example/films/README.txt index 4ba6e007e98..74a29a1ace0 100644 --- a/solr/example/films/README.txt +++ b/solr/example/films/README.txt @@ -15,7 +15,7 @@ This data consists of the following fields: bin/solr start * Create a "films" core: - bin/solr create_core -n films -c data_driven_schema_configs + bin/solr create -c films * Set the schema on a couple of fields that Solr would otherwise guess differently (than we'd like) about: curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:application/json' --data-binary '{ @@ -33,12 +33,12 @@ curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:applicatio * Now let's index the data, using one of these three commands: - - JSON: bin/post films example/films/films.json - - XML: bin/post films example/films/films.xml + - JSON: bin/post -c films example/films/films.json + - XML: bin/post -c films example/films/films.xml - CSV: bin/post \ - films \ + -c films \ example/films/films.csv \ - "params=f.genre.split=true&f.directed_by.split=true&f.genre.separator=|&f.directed_by.separator=|" + -params "f.genre.split=true&f.directed_by.split=true&f.genre.separator=|&f.directed_by.separator=|" * Let's get searching! - Search for 'Batman': @@ -98,7 +98,7 @@ bin/solr stop rm server/logs/*.log rm -Rf server/solr/films/ bin/solr start -bin/solr create_core -n films -c data_driven_schema_configs +bin/solr create -c films curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:application/json' --data-binary '{ "add-field" : { "name":"name", @@ -111,7 +111,7 @@ curl http://localhost:8983/solr/films/schema -X POST -H 'Content-type:applicatio "stored":true } }' -bin/post films example/films/films.json +bin/post -c films example/films/films.json curl http://localhost:8983/solr/films/config/params -H 'Content-type:application/json' -d '{ "update" : { "facets": { diff --git a/solr/site/quickstart.mdtext b/solr/site/quickstart.mdtext index 753e0f0feec..23347bcf5cc 100644 --- a/solr/site/quickstart.mdtext +++ b/solr/site/quickstart.mdtext @@ -76,11 +76,11 @@ many other formats. `SimplePostTool` features the ability to crawl a directory sending the raw content of each file into Solr for extraction and indexing. A Solr install includes a `docs/` subdirectory, so that makes a convenient set of (mostly) HTML files built-in to start with. - bin/post gettingstarted docs/ + bin/post -c gettingstarted docs/ Here's what it'll look like: - /solr5:$ bin/post gettingstarted docs/ + /solr5:$ bin/post -c gettingstarted docs/ SimplePostTool version 1.5 Posting files to base url http://localhost:8983/solr/update.. Entering auto mode. File endings considered are xml,json,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log @@ -123,7 +123,7 @@ Solr's install includes a handful of Solr XML formatted files with example data Using `bin/post`, index the example Solr XML files in `example/exampledocs/`: - bin/post -c gettingstarted example/exampledocs/*.xml (TODO: depends on SOLR-6900) + bin/post -c gettingstarted example/exampledocs/*.xml Here's what you'll see: @@ -165,11 +165,11 @@ Solr supports indexing JSON, either arbitrary structured JSON or "Solr JSON" (wh Solr includes a small sample Solr JSON file to illustrate this capability. Again using `bin/post`, index the sample JSON file: - bin/post -c gettingstarted example/exampledocs/books.json (TODO: depends on SOLR-6900) + bin/post -c gettingstarted example/exampledocs/books.json You'll see: - /solr5:$ bin/post -c gettingstarted example/exampledocs/books.json (TODO: depends on SOLR-6900) + /solr5:$ bin/post -c gettingstarted example/exampledocs/books.json SimplePostTool version 1.5 Posting files to base url http://localhost:8983/solr/update.. Entering auto mode. File endings considered are xml,json,csv,... @@ -190,11 +190,11 @@ index that into Solr rather than a more sophisticated single step operation. Using SimplePostTool and the included example CSV data file, index it: - bin/post -c gettingstarted example/exampledocs/books.csv (TODO: depends on SOLR-6900) + bin/post -c gettingstarted example/exampledocs/books.csv In your terminal you'll see: - /solr5:$ bin/post -c gettingstarted example/exampledocs/books.csv (TODO: depends on SOLR-6900) + /solr5:$ bin/post -c gettingstarted example/exampledocs/books.csv SimplePostTool version 1.5 Posting files to base url http://localhost:8983/solr/update.. Entering auto mode. File endings considered are xml,json,csv,... @@ -562,7 +562,6 @@ on your computer's power and resources available.) Here's a Unix script for convenient copying and pasting in order to run the key commands for this quick start guide: - # TODO: depends on SOLR-6900 date ; bin/solr start -e cloud -noprompt ; open http://localhost:8983/solr ;