Using post.jar for posting JSON, CSV, XML data on Solr
- how to post XML data in form of a XML file using post.jar file?
- how to post CSV data in form of a CSV file using post.jar file?
- how to post JSON data in form of a JSON file using post.jar file?
http://versatileankur.blogspot.in/2014/05/how-to-query-to-apache-solr.html
<parent-directory>/solr-4.7.2/example/exampledocs
For multiple XML files use –
java -jar post.jar dummy.xml dummy1.xml
For all XML files present in working directory use-
java -jar post.jar *.xml
How to post CSV data in form of a CSV file using post.jar file?
first create a CSV file at /example/exampledocs/ directory using these records-
id,name,address,comments,popularity,counts,dynamicField_i
“Solr110″,”Solr 110″,”House No – 100, LR Apache”,”Apache Solr comment 1″,110,110,”dynamic solr 110″
“Solr111″,”Solr 111″,”House No – 100, LR Apache”,”Apache Solr comment 1″,111,111,”dynamic solr 111″
“Solr112″,”Solr 112″,”House No – 100, LR Apache”,”Apache Solr comment 1″,112,112,”dynamic solr 112″
“Solr113″,”Solr 113″,”House No – 100, LR Apache”,”Apache Solr comment 1″,113,113,”dynamic solr 113″
java -Durl=http://localhost:8983/solr/update/csv -Dtype=text/csv -jar post.jar dummy.csv
For multiple CSV files use –
java -Durl=http://localhost:8983/solr/update/csv -Dtype=text/csv -jar post.jar dummy.csv dummy1.csv
For all CSV files present in working directory use-
java -Durl=http://localhost:8983/solr/update/csv -Dtype=text/csv -jar post.jar *.csv
you will get on console a success message as –
SimplePostTool version 1.5
Posting files to base url http://localhost:8983/solr/update/csv using content-type text/csv..
POSTing file dummy.csv
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/update/csv..
Time spent: 0:00:00.577
Congrats your CSV document has been posted successfully.
how to post JSON data in form of a JSON file using post.jar file?
first create a JSON file at /example/exampledocs/ directory using these records
[{
“id”:”Solr115″,
“name”:”Solr 115″,
“address”:”House No – 100, LR Apache, 40702″,
“comments”:”Apache Solr comment 1″,
“popularity”:115,
“counts”:115
},
{
“id”:”Solr116″,
“name”:”Solr 116″,
“address”:”House No – 100, LR Apache, 40702″,
“comments”:”Apache Solr comment 1″,
“popularity”:116,
“counts”:116
},
{
“id”:”Solr117″,
“name”:”Solr 117″,
“address”:”House No – 100, LR Apache, 40702″,
“comments”:”Apache Solr comment 1″,
“popularity”:117,
“counts”:117
}]
java -Durl=http://localhost:8983/solr/update/json -Dtype=application/json -jar post.jar dummy.json
For multiple JSON files use –
java -Durl=http://localhost:8983/solr/update/json -Dtype=application/json -jar post.jar d1.json d2.json
For all JSON files present in working directory use-
java -Durl=http://localhost:8983/solr/update/json -Dtype=application/json -jar post.jar *.json
you will get on console a success message as –
SimplePostTool version 1.5
Posting files to base url http://localhost:8983/solr/update/json using content-type application/json..
POSTing file dummy.json
1 files indexed.
COMMITting Solr index changes to http://localhost:8983/solr/update/json..
Time spent: 0:00:00.535
it means your data JSON document has been indexed in Apache Solr. just go to your dashboard screen
your screen looks like-
this post.jar file provides you some more parameters with <add> tag in XML file. I will discuss them in my later posts.
Namah Shivay
Happy Coding
Namah Shivay
Recent Comments