Today we are going to post data with different file
Import data
For json:
{
"id": "02",
"first_name": ["Abishek"],
"last_name": ["Kafle"],
"title": ["DevOps and Security"],
"cybername": ["anoint"]
}
Now post this main.json file using curl:
curl -X POST \
-H 'Content-Type: application/json' \
'http://127.0.0.1:8983/solr/coder/update/json/docs' \
--data @main.json
You can also update json file as per your requirements.
After POST the json also restart the solr too:
sudo service solr restart
For xml:
<add>
<doc>
<field name="id">02</field>
<field name="first_name">Abishek</field>
<field name="last_name">Kafle</field>
<field name="title">DevOps and Security</field>
<field name="cybername">anoint</field>
</doc>
</add>
Post XML Data to Solr using curl:
curl -X POST \
-H 'Content-Type: application/xml' \
'http://127.0.0.1:8983/solr/coder/update' \
--data-binary @main.xml
Restart Solr:
sudo service solr restart
Delete Data
For json:
1) Delete the specific data from json:
curl -X POST \
'http://127.0.0.1:8983/solr/coder/update/json/docs' \
-H 'Content-Type: application/json' \
--data-binary '{
"delete": {
"query": "id:02"
}
}'
2) Delete all data from json:
curl -X POST \
'http://127.0.0.1:8983/solr/coder/update/json/docs' \
-H 'Content-Type: application/json' \
--data-binary '{
"delete": {
"query": "*:*"
}
}'
For xml:
1) Delete the specific data from xml:
curl -X POST \
'http://127.0.0.1:8983/solr/coder/update' \
-H 'Content-Type: application/xml' \
--data-binary '<delete><query>id:02</query></delete>'
2) Delete all the data from xml:
curl -X POST \
'http://127.0.0.1:8983/solr/coder/update' \
-H 'Content-Type: application/xml' \
--data-binary '<delete><query>*:*</query></delete>'
After deleting documents, you should commit the changes to make them visible in Solr:
curl -X POST \
'http://127.0.0.1:8983/solr/coder/update' \
-H 'Content-Type: application/xml' \
--data-binary '<commit />'
sudo service solr restart
You can also use UI too but cli is preferred:
File Upload
You can also upload your file:
Last updated