最近的一个需求,要把solr的数据导出为文本格式。
参考了以下两个链接:
https://github.com/freedev/solr-import-export-json
https://stackoverflow.com/questions/8176697/how-to-export-solr-result-into-a-text-file
选择使用第一种方式,通过github上的工具进行导出。
需要说明的是,solr是封装在docker中的,首先要看solr映射到哪个端口上了:
1. 首先查看solr占用的端口:docker ps -a |grep solr
查到solr的端口为8081,通过:
http://<ip>:8081/solr/#/ 即可访问solr的数据,在web中查询solr的数据。
2. 安装工具
To execute this console app you need to satisfy few dependency (java 8, git, maven), if you are a java developer probably you already have everything, on the other hand if not if you have Linux execute the following commands:
git clone https://github.com/freedev/solr-import-export-json.git
cd solr-import-export-json
mvn clean package
3.导出数据
export all documents into a json file
./run.sh -s http://localhost:8983/solr/<repository> -a export -o /tmp/collection.json