Currently I am using XML file in solr. I index xml file's data using DataimportHandler with XPathentityProcessor.
Now I want to import data from json file.
Is there any example ?
Regards, Sagar
What you need is something like
curl 'http://localhost:8983/solr/update/json?commit=true' --data-binary @books.json -H 'Content-type:application/json'
Taken from the example.
Source: https://wiki.apache.org/solr/UpdateJSON
If you want import part or the entire collection from a json format, well, there is an alternative.
I wrote a java tool: https://github.com/freedev/solr-import-export-json
This is a java application that imports and exports a Solr collection using SolrJ
. Every document has to be a json object and in the file you are importing you must have a list of lines whereas each line is a json object.
{ "id": 1, "date": "20160101T00:00:00", "text": "some text" }
{ "id": 2, "date": "20160102T00:00:00", "text": "some text" }
{ "id": 3, "date": "20160103T00:00:00", "text": "some text" }
I haven't tried with nested documents, and the keys of json document should be exactly the names of the Solr fields.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With