java -jar post.jar -h](http://upload-images.jianshu.io/upload_images/5778083-da58e4afddbe9a65.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
1.2 解决错误
sudo apt-get install python-software-properties
sudo apt-get install apt-file
apt-file update
apt-file search add-apt-repository
sudo apt-get software-properties-common
至此,问题解决。
1.3 配置环境
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
1.4 测试
java -version
2.安装solr
2.1 获取solr
wget http://archive.apache.org/dist/lucene/solr/6.3.0/solr-6.3.0.gz
2.2 安装solr
apt install unzip
tar zxvf solr-6.3.0.gz
2.3启动solr
cd solr-6.3.0/bin
sudo ./solr start -cloud -p 8983 -force
3.solr中文分词实践
3.1 加载smartcn包
3.2 managed-schema中,新建一个字段类型text_chinese, 用以处理中文分词
3.3 分词测试
中英文混合分词效果
4.solr使用
4.1 post.jar导入数据
java -jar post.jar -h
```![29.PNG](http://upload-images.jianshu.io/upload_images/5778083-0457897f4fa8dbf5.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![30.PNG](http://upload-images.jianshu.io/upload_images/5778083-b1ea842339ae3f19.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
导入gb18030-example.xml
java -Dc=gettingstarted -jar post.jar gb18030-example.xml
导入post.jar books.json(需要指明文件类型)
java -Dtype=application/json -Dc=gettingstarted -jar post.jar books.json
![32.PNG](http://upload-images.jianshu.io/upload_images/5778083-aa95ab494c1ab48e.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
###4.2 查询
第一种方式:使用query查询
![33.PNG](http://upload-images.jianshu.io/upload_images/5778083-d4822b47d06b9ffc.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
右侧查询结果
![34.PNG](http://upload-images.jianshu.io/upload_images/5778083-bfcf77e4df430c0c.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
第二种方式:直接构造查询地址
http://localhost:8983/solr/zjj1/select?wt=xml&indent=true&q=foundation
![35.PNG](http://upload-images.jianshu.io/upload_images/5778083-b512b05c3b9c31aa.PNG?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)