pankaj kashyap
pankaj kashyap

Reputation: 382

solr 6.4.0 post method is not working

I have downloaded solr 6.4.0 version and trying indexing the doucments into a previously created core named "firstcore", I end up with following error:

D:\solr-6.4.0\bin>post -c firstcore example/exampledocs/*.xml

'post' is not recognized as an internal or external command, operable program or batch file.

D:\solr-6.4.0\bin>

Could you please advise me is there any configuration that i need to do/ how to index?

Upvotes: 0

Views: 3015

Answers (2)

ciroBorrelli
ciroBorrelli

Reputation: 25

Here you are a "post.cmd" code for Windows

NOTICE that: is works with Solr7 (for solr6 You should make some adaptations/changes)

@echo off
rem * *****************************************************************
rem *               POST Help                                         *
rem * *****************************************************************
rem * SimplePostTool version 5.0.0
rem * Uses JAVA: java [SystemProperties] -jar post.jar [-h|-] [<file|folder|url|arg> [<file|folder|url|arg>...]]
rem *   -h = prints thsi HELP
rem *   - commits changes to SOLR core/collection
rem *
rem * Supported System Properties and their defaults:
rem *  -Dc=<core/collection>
rem *  -Durl=<base Solr update URL> (overrides -Dc option if specified)
rem *  -Ddata=files|web|args|stdin (default=files)
rem *  -Dtype=<content-type> (default=application/xml)
rem *  -Dhost=<host> (default: localhost)
rem *  -Dport=<port> (default: 8983)
rem *  -Dbasicauth=<user:pass> (sets Basic Authentication credentials)
rem *  -Dauto=yes|no (default=no)
rem *  -Drecursive=yes|no|<depth> (default=0)
rem *  -Ddelay=<seconds> (default=0 for files, 10 for web)
rem *  -Dfiletypes=<type>[,<type>,...] (default=xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log)
rem *  -Dparams="<key>=<value>[&<key>=<value>...]" (values must be URL-encoded)
rem *  -Dcommit=yes|no (default=yes)
rem *  -Doptimize=yes|no (default=no)
rem *  -Dout=yes|no (default=no)
rem
rem * This is a simple command line tool for POSTing raw data to a Solr port.
rem * NOTE: Specifying the url/core/collection name is mandatory.
rem * Data can be read from files specified as commandline args,
rem * URLs specified as args, as raw commandline arg strings or via STDIN.

rem * Examples:
rem *   java -Dc=gettingstarted -jar post.jar *.xml
rem *   java -Ddata=args -Dc=gettingstarted -jar post.jar '<delete><id>42</id></delete>'
rem *   java -Ddata=stdin -Dc=gettingstarted -jar post.jar < hd.xml
rem *   java -Ddata=web -Dc=gettingstarted -jar post.jar http://example.com/
rem *   java -Dtype=text/csv -Dc=gettingstarted -jar post.jar *.csv
rem *   java -Dtype=application/json -Dc=gettingstarted -jar post.jar *.json
rem *   java -Durl=http://localhost:8983/solr/techproducts/update/extract -Dparams=literal.id=pdf1 -jar post.jar solr-word.pdf
rem *   java -Dauto -Dc=gettingstarted -jar post.jar *
rem *   java -Dauto -Dc=gettingstarted -Drecursive -jar post.jar afolder
rem *   java -Dauto -Dc=gettingstarted -Dfiletypes=ppt,html -jar post.jar afolder

rem * The options controlled by System Properties include the Solr
rem * URL to POST to, the Content-Type of the data, whether a commit
rem * or optimize should be executed, and whether the response should
rem * be written to STDOUT. If auto=yes the tool will try to set type
rem * automatically from file name. When posting rich documents the
rem * file name will be propagated as "resource.name" and also used
rem * as "literal.id". You may override these or any other request parameter
rem * through the -Dparams property. To do a commit only, use "-" as argument.
rem * The web mode is a simple crawler following links within domain, default delay=10s.

set CORE=%2
set DELAY=1
set RECURSIVE=%5
set HOST=localhost
set PORT=8983
set FTYPES=%6
set PARAMS="uprefix=attr_^&literal.id=%3"
set DATA=%4
set URI=%1

@echo off
if [%2]==[] goto usage
if [%5]==[] set RECURSIVE=yes
if [%4]==[] set DATA="files"
if [%3]==[] set PARAMS=uprefix=attr_^&literal.id=
if [%6]==[] set FTYPES=
if [%1]==[] goto usage

echo.
echo about to execute:
echo java -Dc=%CORE% -Ddelay=%DELAY% -Drecursive=%RECURSIVE% -Dhost=%HOST% -Dport=%PORT% -Dfiletypes=%FTYPES% -Dparams=%PARAMS% -Ddata=%DATA% -Dauto=yes -jar ../example/exampledocs/post.jar -h %URI%

echo.
cmd /C "java -Dc=%CORE% -Ddelay=%DELAY% -Drecursive=%RECURSIVE% -Dhost=%HOST% -Dport=%PORT% -Dfiletypes=%FTYPES% -Dparams=%PARAMS% -Ddata=%DATA% -Dauto=yes -jar ../example/exampledocs/post.jar %URI%"
goto end

:usage
@echo off
echo.
echo Usage syntax: post "full/url/or/uri-to-document,full/url/or/uri-to-folder" "core/collection name" [document-id] [filetypes:pdf,xml,docx,...] [data-type:files,web,args,stdin] [recursive:yes,no,depth[es: 99]]
echo.
echo Usage example: post "../docs/apache-solr-ref-guide-7.5.pdf" "nur" "apache-solr-ref-guide-7.5.pdf"
echo.
echo HELP:
cmd /C "java -jar ../example/exampledocs/post.jar -h

:end
echo.
echo.

Upvotes: 0

Mysterion
Mysterion

Reputation: 9320

bin/post exists currently only as a Unix shell script, however it delegates its work to a cross-platform capable Java program. The SimplePostTool can be run directly in supported environments, including Windows.

This tool, bundled into a executable JAR, can be run directly using java -jar example/exampledocs/post.jar.

Please check you, that you have post.jar in your Solr installation under this path, and that you have Java installed and configured to be access through PATH

Upvotes: 1

Related Questions