创建一个Solr home目录,存储运行Solr实例所有的配置文件和数据(Lucene索引文件)。
将F:\develop\solr作为Solr Home。
1. 将example\solr下的内容 拷贝至 F:\develop\solr目录下
2. 修改F:\develop\solr\collection1\conf目录下solrconfig.xml文件,将dataDir节点的值指向F:\develop\solr。如下图所示:
<requestHandler name="/dataimport" class="solr.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>将以上代码放在<requestHandler name="/select" class="solr.SearchHandler">的上面,其实放哪里都可以,只要是在config标签里就行了
<?xml version="1.0" encoding="UTF-8" ?> <dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.2.201:3306/book_publishing" user="root" password="root"/> <document name="book_publishing"> <entity name="book" transformer="HTMLStripTransformer" query="select id,name,author,keyword,intro,editor,edition,cover,publishDate,resourceType,classifyCode,price from book"> <field column="id" name="id" /> <field column="name" name="title" /> <field column="resourceType" name="resourcetype" /> <field column="author" name="author" /> <field column="keyword" name="keyword" /> <field column="intro" name="content" stripHTML="true"/> <field column="cover" name="url" /> <field column="publishDate" name="publishdate" /> <field column="classifyCode" name="classifycode" /> <field column="price" name="price" /> </entity> <entity name="content" transformer="HTMLStripTransformer" query="select contentid,markid,title,author,keyword,intro,bookName,resourceType,classifyCode,price from content"> <field column="contentid" name="id" /> <field column="title" name="title" /> <field column="resourceType" name="resourcetype" /> <field column="author" name="author" /> <field column="keyword" name="keyword" /> <field column="intro" name="content" stripHTML="true"/> <field column="bookName" name="bookname" /> <field column="classifyCode" name="classifycode" /> <field column="price" name="price" /> </entity> <entity name="resource" transformer="HTMLStripTransformer" query="select resourceid,resourceName,author,keyword,intro,bookid,bookName,path,resourceType,classifyCode,price from resource"> <field column="resourceid" name="id" /> <field column="resourceName" name="title" /> <field column="resourceType" name="resourcetype" /> <field column="author" name="author" /> <field column="keyword" name="keyword" /> <field column="intro" name="content" stripHTML="true"/> <field column="bookid" name="bookid" /> <field column="bookName" name="bookname" /> <field column="path" name="url" /> <field column="classifyCode" name="classifycode" /> <field column="price" name="price" /> </entity> </document> </dataConfig>