文章目录
Server : Ubuntu 16.04
Java Version : 1.8
Solr Version : 7.4.0
一、数据准备
Solr 刚刚安装后,是没有任何数据的,所以此时我们无法进行任何查询。幸运的是,官方为用户提供了索引工具以及样本数据,方便新手快速建立索引。
首先,我们先看一下索引工具和样本数据分别位于哪个位置。
- 索引工具:
/{solr_home}/bin/post
- 样本数据:
/{solr_home}/example/exampledocs
在样本数据中,包含了 json
、csv
、xml
、html
等多种格式的数据。尽管如此,官方提供的 post
工具只需一个命令即可为上述多种格式的数据建立索引:
./post -c techproducts ../example/exampledocs/*
成功运行命令,我们看到以下信息输出:
SimplePostTool version 5.0.0
Posting files to [base] url http://localhost:8983/solr/testCollection/update...
Entering auto mode. File endings considered are xml,json,jsonl,csv,pdf,doc,docx,ppt,pptx,xls,xlsx,odt,odp,ods,ott,otp,ots,rtf,htm,html,txt,log
POSTing file books.csv (text/csv) to [base]
POSTing file books.json (application/json) to [base]/json/docs
POSTing file gb18030-example.xml (application/xml) to [base]
POSTing file hd.xml (application/xml) to [base]
POSTing file ipod_other.xml (application/xml) to [base]
POSTing file ipod_video.xml (application/xml) to [base]
POSTing file manufacturers.xml (application/xml) to [base]
POSTing file mem.xml (application/xml) to [base]
POSTing file money.xml (application/xml) to [base]
POSTing file monitor2.xml (application/xml) to [base]
POSTing file monitor.xml (application/xml) to [base]
POSTing file more_books.jsonl (application/json) to [base]/json/docs
POSTing file mp500.xml (application/xml) to [base]
POSTing file post.jar (application/octet-stream) to [base]/extract
POSTing file sample.html (text/html) to [base]/extract
POSTing file sd500.xml (application/xml) to [base]
POSTing file solr-word.pdf (application/pdf) to [base]/extract
POSTing file solr.xml (application/xml) to [base]
POSTing file test_utf8.sh (application/oc