一:安装jdk1.8
下载solr的安装目录 https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.2.0/solr-6.2.0.zip
solr的入门文档http://lucene.apache.org/solr/quickstart.html
二:solr到新版本不需要再特别配置tomcat了,在解压目录的bin就可以直接使用
1 启动:>>solr start -e cloud -noprompt
这里的solr是bin下的cmd文件,start是启动cloud表示使用SolrClound example,noprompt 表示全部使用默认配置。
系统内置的example有cloud, dih, schemaless, or techproducts 这几种。
2 关闭 >>solr stop -all
3 帮助solr提供了好几个help,比如:>>solr -help >>solr create -help
4,执行1之后就可以在 http://localhost:8983/solr/ 看到solr的管理员界面了。
5,在浏览器点击Collection select,选择其中一个,点击Quary。
三:根据文档http://lucene.apache.org/solr/quickstart.html,导入信息需要post。我在bin目录下看到post在windows7没法使用,后来看到是使用 H:\mysolr\solr-6.2.0\example\exampledocs下的post.jar。
1:使用post
比如:>>java -Dc=gettingstarted -jar post.jar aa.xml" 这里的aa.xml应该和post.jar在一个目录。默认是xml,如果不是xml,需要指定文件格式>>java -Dtype=application/json -Dc=gettingstarted -jar post.jar b.json
现在我使用的aa.xml是这样的
==
<add>
<doc>
<field name="id">1</field>
<field name="title">我的测试</field>
<field name="url">http://www.baidu.com</field>
</doc>
</add>
刚开始报错,是因为编码原因,在notepad++中改了一下编码就好了。
2:在浏览器里面quary试试
3:java -Dtype=application/json -jar post.jar *.json 批量
==