上篇文章讲了基本的solr平台的搭建。
这里接着讲解solr索引库的创建。
1、在webapps中solr中solrhome目录下新建一个文件夹名字叫做myindex(名字不固定,可以随便取,但是这个名字在后面的配置中会有所关联)。
2、然后在myindex文件下新建一个名字叫做conf的文件夹(这个文件名字最后不要改)
3、然后把官网下下来的solr项目中solr-6.2.0\server\solr\configsets\data_driven_schema_configs\conf下的所有东西复制到conf中去。(注意不要复制错)
4、最后把solr-6.2.0\example\example-DIH\solr\db\conf下的admin-extra.html,admin-extra.menu-bottom.html ,admin-extra.menu-top.html三个文件也复制到conf中去。
如下图:
5、然后将solrconfig.xml文件中的以下部分注释掉,防止启动日志报警告。
6、最后在conf文件下的managed-schema配置field信息:
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="string" indexed="true" stored="true" />
<field name="synopsis" type="string" indexed="true" stored="true" />
<field name="updateTime" type="date" indexed="true" stored="true" />
<field name="_version_" type="long" indexed="true" stored="false"/>
<field name="_root_" type="string" indexed="true" stored="false" docValues="false" />
<field name="_text_" type="text_general" indexed="true" stored="false" multiValued="true"/>
其中id,title,synopsis,updateTime是数据库中的字段。配置文件详解
下面三个field是Solr系统本身的不能删除,否则会运行错误。
7、启动Tomcat,打开http://localhost:8080/solr/index.html地址,选Core Admin然后点Add Core 输入内容如下图:
点确定即可。如下即添加成功。
成功后myindex索引库的文件结构和内容变化如下: