solr配置,
1 、先准备 apache-solr-1.4.1.zip ,还有 apache-tomcat-6.0.18.zip
2 、各自解压,在 e :建立一个 solr 文件夹,将 apache-solr-1.4.1.zip 解压后的目录下的 dist 目录下的 apache-solr-1.4.1.war 复制到 e:/solr 中去
3 、将 apache-solr-1.4.1.war 解压到当前目录下
4 、打开解压后的 tomcat 目录下的 conf 目录,打开 server.xml 设定一下 tomcat 编码,如下
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/> |
1、 在 tomcat 下的 conf 中建立 Catalina/localhost/solr.xml ,内容如下:
<?xml version="1.0" encoding="utf-8"?> <Context docBase="E:/solr/apache-solr-1.4.1.war" reloadable="true" > <Environment name="solr/home" type="java.lang.String" value="E:/solr/solr" override="true" /> </Context> |
2、 从一开始解压的 solr 目下的 example/example-DIH/solr/db 中的 conf 拷贝到 e:/solr/solr 中去
3、 配置数据源, db-data-config.xml ,如下配置的是 MySQL 的数据源
<dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/op" user="root" password="root"/> <document> <entity name="prorelease" query="select * from pro_release" > <field column="content_id" name="solr_contentid" /> <field column="author" name="solr_author" /> <field column="content" name="solr_content" />
</entity> </document> |
4、 配置一下 schema.xml ,
( 1 )找到 < fields> 节点,有下面的去替换所有的 <field> 节点
<field name="solr_contentid" type="string" indexed="true" stored="true" required="true" /> <field name="solr_author" type="string" indexed="true" stored="true" /> <field name="solr_content" type="string" indexed="true" stored="true" /> |
( 2 )找到 < uniqueKey>, 设定为 <uniqueKey> solr_contentid </uniqueKey>;
( 3 )找到 < defaultSearchField > ,设定为 <defaultSearchField> solr_author </defaultSearchField>;
( 4 )删除所有的 <copyField>
10 、在 e:/solr/solr 下建立一个 lib 目录,加入 mysql 驱动
11 、 http:// localhost:8080/solr/admin/dataimport.jsp 导入数据
12 、 http://localhost:8080/solr/admin/ ,输入一个作者名称,就可以检索出想要的数据了