﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-海水正蓝-随笔分类-Solr</title><link>http://www.blogjava.net/xiaohuzi2008/category/53075.html</link><description>面朝大海，春暖花开</description><language>zh-cn</language><lastBuildDate>Mon, 03 Dec 2012 10:33:19 GMT</lastBuildDate><pubDate>Mon, 03 Dec 2012 10:33:19 GMT</pubDate><ttl>60</ttl><item><title>【转】Solr 缓存配置</title><link>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392376.html</link><dc:creator>小胡子</dc:creator><author>小胡子</author><pubDate>Mon, 03 Dec 2012 08:54:00 GMT</pubDate><guid>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392376.html</guid><wfw:comment>http://www.blogjava.net/xiaohuzi2008/comments/392376.html</wfw:comment><comments>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392376.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaohuzi2008/comments/commentRss/392376.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaohuzi2008/services/trackbacks/392376.html</trackback:ping><description><![CDATA[<div><div align="left"><div align="left">缓存在 Solr 中充当了一个非常重要的角色，Solr 中主要有这三种缓存：</div><ul><li>Filter cache（过滤器缓存），用于保存过滤器（fq 参数）和层面搜索的结果</li><li>Document cache（文档缓存），用于保存 lucene 文档存储的字段</li><li>Query result（查询缓存），用于保存查询的结果<br /> </li></ul>还有第四种缓存，lucene 内部的缓存，不过该缓存外部无法控制到。<br /> <br /> 通过这 3 种缓存，可以对 solr 的搜索实例进行调优。调整这些缓存，需要根据索引库中文档的数量，每次查询结果的条数等。<br /> 在调整参数前，需要事先得到 solr 示例中的以下信息：<br /> <ul><li>索引中文档的数量</li><li>每秒钟搜索的次数</li><li>过滤器的数量</li><li>一次查询返回最大的文档数量</li><li>不同查询和不同排序的个数<br /> </li></ul>这些数量可以在 solr admin 页面的日志模块找到。假设以上的值分别为：<br /> <br /> <ul><li>索引中文档的数量：1000000</li><li>每秒钟搜索的次数：100</li><li>过滤器的数量：200</li><li>一次查询返回最大的文档数量：100</li><li>不同查询和不同排序的个数：500<br /> </li></ul>然后可以开始修改 solrconfig.xml 中缓存的配置了，第一个是过滤器缓存：<br /> <br /> &lt;filterCache class="solr.FastLRUCache" size="200" initialSize="200"&nbsp;&nbsp;autowarmCount="100"/&gt;<br /> <div align="left">第二个是查询结果缓存：</div><br /> &lt;queryResultCache class="solr.FastLRUCache" size="500" initialSize="500" autowarmCount="250"/&gt; <br /> <div align="left">第三个是文档缓存：</div><br /> &lt;documentCache class="solr.FastLRUCache" size="11000" initialSize="11000" /&gt; <br /> <div align="left">这几个配置是基于以上的几个假设的值进行调优的。</div></div></div>原文出自：<div>http://insolr.com/forum.php?mod=viewthread&amp;tid=7&amp;reltid=880&amp;pre_thread_id=19&amp;pre_pos=5&amp;ext=</div><img src ="http://www.blogjava.net/xiaohuzi2008/aggbug/392376.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaohuzi2008/" target="_blank">小胡子</a> 2012-12-03 16:54 <a href="http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392376.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】solr导入数据库</title><link>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392375.html</link><dc:creator>小胡子</dc:creator><author>小胡子</author><pubDate>Mon, 03 Dec 2012 08:51:00 GMT</pubDate><guid>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392375.html</guid><wfw:comment>http://www.blogjava.net/xiaohuzi2008/comments/392375.html</wfw:comment><comments>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392375.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaohuzi2008/comments/commentRss/392375.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaohuzi2008/services/trackbacks/392375.html</trackback:ping><description><![CDATA[<div>一.首先准备好solr的dataimport功能需要的东西，在solr的下载包中。分别在： <br /> 1》Solr-1.3.0\dist\apache-solr-dataimporthandler-1.3.0.jar <br /> 2》E:\education\search\Solr-1.3.0\example\example-DIH\solr\ <br /> 3》你是哪种数据库，提供该数据库的jdbc驱动。 <br /> <br /> 二.如果你还不会运行solr，请参考本人的前几篇博客。这里要做的是，先把E:\education\search\Solr-1.3.0 \example\example-DIH\solr\下面的东西拷贝到solr的HOME目录，然后删除rss，这个是另外一个功能是导入rss订阅信 息到solr中，确实很强，这都想到了。将jar文件，实际就两个拷贝到tomcat的webapps下面的solr的WEB-INF的lib文件夹下 面。 <br /> <br /> 三.更改solr Home目录下的conf/solrconfig.xml，其实就是提交一个solrRequestHandler,代码如下： <ul type="1"><li><strong>&lt;requestHandler</strong> name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"<strong>&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp; <strong>&lt;lst</strong> name="defaults"<strong>&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;str</strong> name="config"<strong>&gt;</strong>C:\solr-tomcat\solr\db\conf\db-data-config.xml<strong>&lt;/str&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp; <strong>&lt;/lst&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp;&nbsp;<strong>&lt;/requestHandler&gt;</strong>&nbsp;&nbsp;<br /> </li></ul><br /> &lt;requestHandler name="/dataimport"  class="org.apache.solr.handler.dataimport.DataImportHandler"&gt;&nbsp; &nbsp;  &lt;lst name="defaults"&gt;&nbsp; &nbsp;&nbsp; &nbsp;&lt;str  name="config"&gt;C:\solr-tomcat\solr\db\conf\db-data-config.xml&lt;/str&gt;&nbsp;  &nbsp; &lt;/lst&gt;&nbsp;&nbsp;&lt;/requestHandler&gt;<br /> <br /> 四.将solr Home目录下面的solrconfig.xml和schema.xml拷贝到db文件夹下面的conf中。 <br /> <br /> 五.修改db\conf\db-data-config.xml <ul type="1"><li><strong>&lt;dataConfig&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<strong>&lt;dataSource</strong> type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/tuitui" user="root" password="mysql"<strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp; <strong>&lt;document</strong> name="shop"<strong>&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;entity</strong> name="tuitui_shop" pk="shopId" query="select * from tuitui_shop"<strong>&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="shopid" name="shopId" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="shopName" name="shopName" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="shopUrl" name="shopUrl" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="keyword" name="keyword" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="synopsis" name="synopsis" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="province" name="province" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="city" name="city" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="domain" name="domain" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="address" name="address" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="coordinate" name="coordinate" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="shopSspn" name="shopSspn" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="phone" name="phone" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<strong>&lt;field</strong> column="createTime" name="createTime" <strong>/&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<strong>&lt;/entity&gt;</strong>&nbsp;&nbsp;</li><li>&nbsp; &nbsp; <strong>&lt;/document&gt;</strong>&nbsp;&nbsp;</li><li><strong>&lt;/dataConfig&gt;</strong>&nbsp;&nbsp;<br /> </li></ul><br /> &lt;dataConfig&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;dataSource type="JdbcDataSource"  driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/tuitui"  user="root" password="mysql"/&gt;&nbsp; &nbsp; &lt;document name="shop"&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp; &nbsp;&lt;entity name="tuitui_shop" pk="shopId" query="select * from  tuitui_shop"&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field column="shopid" name="shopId"  /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field column="shopName" name="shopName" /&gt;&nbsp; &nbsp;&nbsp;  &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field column="shopUrl" name="shopUrl" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&lt;field column="keyword" name="keyword" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field  column="synopsis" name="synopsis" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field  column="province" name="province" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field  column="city" name="city" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field column="domain"  name="domain" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field column="address" name="address"  /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field column="coordinate" name="coordinate" /&gt;&nbsp;  &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field column="shopSspn" name="shopSspn" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;  &nbsp;&lt;field column="phone" name="phone" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&lt;field  column="createTime" name="createTime" /&gt;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;/entity&gt;&nbsp; &nbsp;  &lt;/document&gt;&lt;/dataConfig&gt;<br /> <br /> 其中的意思我做简单解释，具体大家可以去看看官方wiki。 <br /> document：一个文档也就是lucene的document这个没什么解释的； <br /> entity：主要针对的是一个数据库表； <br /> filed：属性column是数据库的字段，name是filed的名字，即schema中的field name <br /> <a href="http://wiki.apache.org/solr/DataImportHandler" target="_blank">http://wiki.apache.org/solr/DataImportHandler</a> <br /> <br /> 六.启动TOMCAT，输入地址进行导入，导入分为很多模式：我选用的全部倒入模式。 <br /> <br /> http://localhost/solr/dataimport?command=full-import </div>原文出自：<div>http://insolr.com/forum.php?mod=viewthread&amp;tid=128&amp;reltid=880&amp;pre_thread_id=19&amp;pre_pos=4&amp;ext=</div><img src ="http://www.blogjava.net/xiaohuzi2008/aggbug/392375.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaohuzi2008/" target="_blank">小胡子</a> 2012-12-03 16:51 <a href="http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392375.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】solr与tomcat 集成</title><link>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392374.html</link><dc:creator>小胡子</dc:creator><author>小胡子</author><pubDate>Mon, 03 Dec 2012 08:50:00 GMT</pubDate><guid>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392374.html</guid><wfw:comment>http://www.blogjava.net/xiaohuzi2008/comments/392374.html</wfw:comment><comments>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392374.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaohuzi2008/comments/commentRss/392374.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaohuzi2008/services/trackbacks/392374.html</trackback:ping><description><![CDATA[<div>先从网址<br /> <a href="http://labs.mop.com/apache-mirror/lucene/solr/3.6.1/apache-solr-3.6.1.zip" target="_blank">http://labs.mop.com/apache-mirror/lucene/solr/3.6.1/apache-solr-3.6.1.zip</a> 下载程序文件<br /> <br /> 1.解压开找到apache-solr-3.6.1\apache-solr-3.6.1\dist目录下的apache-solr-3.6.1.war<br /> 直接放到tomcat/webapps下面<br /> <br /> 2.先别急着启动慢慢来,修改配置文件apache-solr-3.6.1\WEB-INF\web.xml<br /> 找到:<br /> &nbsp;&nbsp;&lt;!-- People who want to hardcode their "Solr Home" directly into the<br /> &nbsp; &nbsp;&nbsp; &nbsp; WAR File can set the JNDI property here...<br /> &nbsp; &nbsp;--&gt;<br /> &nbsp;&nbsp;&lt;!--<br /> &nbsp; &nbsp; &lt;env-entry&gt;<br /> &nbsp; &nbsp;&nbsp; &nbsp; &lt;env-entry-name&gt;solr/home&lt;/env-entry-name&gt;<br /> &nbsp; &nbsp;&nbsp; &nbsp; &lt;env-entry-value&gt;/put/your/solr/home/here&lt;/env-entry-value&gt;<br /> &nbsp; &nbsp;&nbsp; &nbsp; &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;<br /> &nbsp; &nbsp; &lt;/env-entry&gt;<br /> &nbsp; &nbsp;--&gt;<br /> 更改这为<br /> &nbsp;&nbsp;&lt;!-- People who want to hardcode their "Solr Home" directly into the<br /> &nbsp; &nbsp;&nbsp; &nbsp; WAR File can set the JNDI property here...<br /> &nbsp; &nbsp;--&gt;<br /> &nbsp; &nbsp; &lt;env-entry&gt;<br /> &nbsp; &nbsp;&nbsp; &nbsp; &lt;env-entry-name&gt;solr/home&lt;/env-entry-name&gt;<br /> &nbsp; &nbsp;&nbsp; &nbsp; &lt;env-entry-value&gt;d:/solr_work/solr&lt;/env-entry-value&gt;<br /> &nbsp; &nbsp;&nbsp; &nbsp; &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;<br /> &nbsp; &nbsp; &lt;/env-entry&gt;<br /> &nbsp;&nbsp;注:红色字体的文件夹为apache-solr-3.6.1\example\solr 该应用（此为单核应用,多核以后会讲到）放大D盘的新建空目录solr_work目录下就可以<br /> <br /> <br /> 3.启动tomcat,输入<a href="http://localhost:8080/solr" target="_blank">http://localhost:8080/solr</a>&nbsp;&nbsp;solr应用搭建成功</div>原文出自：<div>http://insolr.com/forum.php?mod=viewthread&amp;tid=3&amp;reltid=880&amp;pre_thread_id=19&amp;pre_pos=6&amp;ext=</div><img src ="http://www.blogjava.net/xiaohuzi2008/aggbug/392374.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaohuzi2008/" target="_blank">小胡子</a> 2012-12-03 16:50 <a href="http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392374.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【转】Solr 4.0部署</title><link>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392373.html</link><dc:creator>小胡子</dc:creator><author>小胡子</author><pubDate>Mon, 03 Dec 2012 08:48:00 GMT</pubDate><guid>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392373.html</guid><wfw:comment>http://www.blogjava.net/xiaohuzi2008/comments/392373.html</wfw:comment><comments>http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392373.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/xiaohuzi2008/comments/commentRss/392373.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/xiaohuzi2008/services/trackbacks/392373.html</trackback:ping><description><![CDATA[<div> 本文只是Solr 4.0的基础教程，本人不经常写东西，写的不好请见谅，欢迎到群233413850进行讨论学习。<br />&nbsp; &nbsp;&nbsp; &nbsp; 先说一点部署之后肯定会有人用solrj，solr 4.0好像添加了不少东西，其中CommonsHttpSolrServer这个类改<br /> <p style="line-height:16px;text-indent:nullem;text-align:left">名为HttpSolrServer，我是找了半天才发现，大家以后可以注意。</p><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp;&nbsp;部署前准备:</p><ul><li>Solr 必须运行在Java1.5 或更高版本的Java 虚拟机中，运行标准Solr 服务只需要安装JRE 即可。</li><li>Solr 4.0 :&nbsp;&nbsp;<a href="http://www.apache.org/dyn/closer.cgi/lucene/solr/4.0.0" target="_blank">http://www.apache.org/dyn/closer.cgi/lucene/solr/4.0.0</a></li><li>本文以Tomcat7.0&nbsp;&nbsp;进行演示。<br /> </li></ul><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">Solr 4.0 目录:</p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<img id="aimg_WjaA3" src="http://static.oschina.net/uploads/space/2012/1030/181101_C5dW_102055.png" alt="" border="0" height="272" width="251" /></p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;这里是我的部署方式，Tomcat安装好之后把apache-solr-4.0.0\example\webapps下的solr.war文件拷贝到Tomcat下的</p><p style="line-height:16px;text-indent:nullem;text-align:left">Tomcat7.0\webapps目录下，然后启动Tomcat 报错不用管，solr.war会自动解压，之后打开Tomcat7.0\webapps\solr\WEB-</p><p style="line-height:16px;text-indent:nullem;text-align:left">INF\web.xml，把下面代码复制进去放到后面：</p><div><div id="code_860"><ol><li>&lt;env-entry&gt;&nbsp; &nbsp; <br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&lt;env-entry-name&gt;solr/home&lt;/env-entry-name&gt;&nbsp; &nbsp;<br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&lt;env-entry-value&gt;E:\SolrHome&lt;/env-entry-value&gt;&nbsp; &nbsp; <br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt; <br /> </li><li>&nbsp; &nbsp; &lt;/env-entry&gt;</li></ol></div><em>复制代码</em></div><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;其中&nbsp;&nbsp;E:\SolrHome&nbsp;&nbsp;是存放solr配置文件等，修改为自己文件的位置，为了看着更清晰直观，你可以这样放:</p><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;E:\Tomcat7.0</p><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;E:\apache-solr-4.0.0</p><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;E:\SolrHome</p><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;现在可以重新启动Tomcat了，没有报错，通过这个地址进入Solr4.0页面:<a href="http://localhost:8080/solr" target="_blank">http://localhost:8080/solr</a> </p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<img style="cursor: pointer;" id="aimg_74kJ4" src="http://static.oschina.net/uploads/space/2012/1030/183427_LBJ3_102055.png" alt="" border="0" height="281" width="600" /></p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;如果进入以上界面说明成功了，没有成功的话页面会有ERROR提示。</p><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;如图：左侧core0,core1等是solr 4.0中的示例，core0和core1位于apache-solr-4.0.0\example\multicore所有文件都下拷贝</p><p style="line-height:16px;text-indent:nullem;text-align:left">到E:\SoleHome下，core0和core1可以理解为两个库，都是独立的，用来存放索引以及生成这些索引文件所需要的配置文件，solrtest是我测试建立的目录，如图：</p><p style="line-height:16px;text-indent:nullem;text-align:left"><img id="aimg_FlQ0f" src="http://static.oschina.net/uploads/space/2012/1030/184643_P24d_102055.png" alt="" border="0" height="176" width="230" /></p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;没添加一个库都需要在solr.xml里面进行配置，这个比较简单</p><div><div id="code_d5H"><ol><li>&lt;solr persistent="false"&gt;&nbsp;&nbsp;<br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;cores adminPath="/admin/cores" host="${host:}" hostPort="${jetty.port:}"&gt;&nbsp; &nbsp; <br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;core name="core0" instanceDir="core0" /&gt;&nbsp; &nbsp; <br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;core name="core1" instanceDir="core1" /&gt;&nbsp; &nbsp; <br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;core name="collection1" instanceDir="collection1" /&gt;&nbsp; &nbsp;<br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&lt;core name="solrtest" instanceDir="solrtest"/&gt; <br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &lt;/cores&gt;<br /> </li><li>&nbsp; &nbsp;&lt;/solr&gt;</li></ol></div><em>复制代码</em></div><strong> name=""，是库的名字，instanceDir=""，是目录</strong><br /> <p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;每个目录下包含两个文件夹conf和data，data下有两个文件夹index和tlog，index是存放生成的索引文件，tlog存放log，</p><p style="line-height:16px;text-indent:nullem;text-align:left">conf下是必要的配置文件schema.xml和solrconfig.xml，可以参考官方或者core里面的配置文件：</p><div><div id="code_ht0"><ol><li>&lt;?xml version="1.0" ?&gt;<br /> </li><li>&lt;schema name="example solr test" version="1.1"&gt;<br /> </li><li>&nbsp;&nbsp;&lt;types&gt;<br /> </li><li>&nbsp; &nbsp;&lt;fieldtype name="string"&nbsp;&nbsp;class="solr.StrField" sortMissingLast="true" omitNorms="true"/&gt;<br /> </li><li>&nbsp; &nbsp;&lt;fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/&gt;<br /> </li><li>&nbsp;&nbsp;&lt;/types&gt;<br /> </li><li><br /> </li><li> &lt;fields&gt;&nbsp; &nbsp;<br /> </li><li>&nbsp;&nbsp;&lt;!-- general --&gt;<br /> </li><li>&nbsp;&nbsp;&lt;field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/&gt;<br /> </li><li>&nbsp;&nbsp;&lt;field name="type" type="string" indexed="true" stored="true" multiValued="false" /&gt; <br /> </li><li>&nbsp;&nbsp;&lt;field name="name" type="string" indexed="true" stored="true" multiValued="false" /&gt;<br /> </li><li>&nbsp;&nbsp;&lt;field name="_version_" type="long" indexed="true" stored="true"/&gt;<br /> </li><li> &lt;/fields&gt;<br /> </li><li><br /> </li><li> &lt;!-- field to use to determine and enforce document uniqueness. --&gt;<br /> </li><li> &lt;uniqueKey&gt;id&lt;/uniqueKey&gt;<br /> </li><li><br /> </li><li> &lt;!-- field for the QueryParser to use when an explicit fieldname is absent --&gt;<br /> </li><li> &lt;defaultSearchField&gt;name&lt;/defaultSearchField&gt;<br /> </li><li><br /> </li><li> &lt;!-- SolrQueryParser configuration: defaultOperator="AND|OR" --&gt;<br /> </li><li> &lt;solrQueryParser defaultOperator="OR"/&gt;<br /> </li><li>&lt;/schema&gt;</li></ol></div><em>复制代码</em></div><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;solrconfig.xml我还不是很懂，在这里就不讲了，但是必须配置（好像是必须配）：</p><div><div id="code_XJA"><ol><li>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br /> </li><li>&lt;!-- 可以从core文件中copy过来 --&gt;<br /> </li><li>&lt;config&gt;<br /> </li><li>&nbsp;&nbsp;&lt;luceneMatchVersion&gt;LUCENE_40&lt;/luceneMatchVersion&gt;<br /> </li><li>&nbsp;&nbsp;<br /> </li><li>&nbsp;&nbsp;&lt;directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/&gt;<br /> </li><li><br /> </li><li>&nbsp;&nbsp;&lt;dataDir&gt;${solr.solrtest.data.dir:}&lt;/dataDir&gt;&nbsp; &nbsp;这里solr.后面名字改掉<br /> </li><li><br /> </li><li>&nbsp;&nbsp;&lt;updateHandler class="solr.DirectUpdateHandler2"&gt;<br /> </li><li>&nbsp; &nbsp; &lt;updateLog&gt;<br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&lt;str name="dir"&gt;${solr.solrtest.data.dir:}&lt;/str&gt;<br /> </li><li>&nbsp; &nbsp; &lt;/updateLog&gt;<br /> </li><li>&nbsp;&nbsp;&lt;/updateHandler&gt;<br /> </li><li><br /> </li><li>&nbsp;&nbsp;&lt;requestHandler name="/get" class="solr.RealTimeGetHandler"&gt;<br /> </li><li>&nbsp; &nbsp; &lt;lst name="defaults"&gt;<br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&lt;str name="omitHeader"&gt;true&lt;/str&gt;<br /> </li><li>&nbsp; &nbsp; &lt;/lst&gt;<br /> </li><li>&nbsp;&nbsp;&lt;/requestHandler&gt;<br /> </li><li>&nbsp;&nbsp;<br /> </li><li>&nbsp;&nbsp;&lt;requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" /&gt; <br /> </li><li><br /> </li><li>&nbsp;&nbsp;&lt;requestDispatcher handleSelect="true" &gt;<br /> </li><li>&nbsp; &nbsp; &lt;requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" /&gt;<br /> </li><li>&nbsp;&nbsp;&lt;/requestDispatcher&gt;<br /> </li><li>&nbsp;&nbsp;<br /> </li><li>&nbsp;&nbsp;&lt;requestHandler name="standard" class="solr.StandardRequestHandler" default="true" /&gt;<br /> </li><li>&nbsp;&nbsp;&lt;requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" /&gt;<br /> </li><li>&nbsp;&nbsp;&lt;requestHandler name="/update" class="solr.UpdateRequestHandler"&nbsp;&nbsp;/&gt;<br /> </li><li>&nbsp;&nbsp;&lt;requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" /&gt;<br /> </li><li><br /> </li><li>&nbsp;&nbsp;&lt;requestHandler name="/admin/ping" class="solr.PingRequestHandler"&gt;<br /> </li><li>&nbsp; &nbsp; &lt;lst name="invariants"&gt;<br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&lt;str name="q"&gt;solrpingquery&lt;/str&gt;<br /> </li><li>&nbsp; &nbsp; &lt;/lst&gt;<br /> </li><li>&nbsp; &nbsp; &lt;lst name="defaults"&gt;<br /> </li><li>&nbsp; &nbsp;&nbsp; &nbsp;&lt;str name="echoParams"&gt;all&lt;/str&gt;<br /> </li><li>&nbsp; &nbsp; &lt;/lst&gt;<br /> </li><li>&nbsp;&nbsp;&lt;/requestHandler&gt;<br /> </li><li><br /> </li><li>&nbsp;&nbsp;&lt;!-- config for the admin interface --&gt; <br /> </li><li>&nbsp;&nbsp;&lt;admin&gt;<br /> </li><li>&nbsp; &nbsp; &lt;defaultQuery&gt;solr&lt;/defaultQuery&gt;<br /> </li><li>&nbsp;&nbsp;&lt;/admin&gt;<br /> </li><li><br /> </li><li>&lt;/config&gt;</li></ol></div><em>复制代码</em></div><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;之后在exampledocs目录下手动创建一个solr1.xml文件：</p><div><div id="code_zZ9"><ol><li>&lt;?xml version="1.0" ?&gt;<br /> </li><li>&lt;add&gt;<br /> </li><li>&nbsp;&nbsp;&lt;doc&gt;<br /> </li><li>&nbsp; &nbsp; &lt;field name="id"&gt;solr1&lt;/field&gt;<br /> </li><li>&nbsp; &nbsp; &lt;field name="type"&gt;type1&lt;/field&gt;<br /> </li><li>&nbsp; &nbsp; &lt;field name="name"&gt;my solr test&lt;/field&gt;<br /> </li><li>&nbsp;&nbsp;&lt;/doc&gt;<br /> </li><li>&lt;/add&gt;</li></ol></div><em>复制代码</em></div><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;跟schema.xml中的字段对应，好了现在可以提交数据了，这里在window命令窗口提交数据，把E:\apache-solr-</p><p style="line-height:16px;text-indent:nullem;text-align:left">4.0.0\example\exampledocs下的post.jar复制到 E:\SolrHome\exampledocs下</p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;打开命令窗口CD 到E:\SolrHome\exampledocs下使用命令，Tomcat不要忘了开：</p><p style="line-height:16px;text-indent:nullem;text-align:left">java -Durl=http://localhost:8080/solr/solrtest/update -Ddata=files -jar post.jar solr1.xml<br /> </p><br /> <br /> <p style="line-height:16px;text-indent:nullem;text-align:left"><img style="cursor: pointer;" id="aimg_exTHh" src="http://static.oschina.net/uploads/space/2012/1030/192511_siNE_102055.png" alt="" border="0" height="166" width="600" /><br /> </p><br /> <br /> <p style="line-height:16px;text-indent:nullem;text-align:left">如图成功的添加的索引，看下E:\SolrHome\solrtest\data\index下的文件：</p><p style="line-height:16px;text-indent:nullem;text-align:left"><img id="aimg_DYICq" src="http://static.oschina.net/uploads/space/2012/1030/192804_IAYR_102055.png" alt="" border="0" height="304" width="264" /><br /> </p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;进入solr页面：<br /> </p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<img style="cursor: pointer;" id="aimg_EMmCT" src="http://static.oschina.net/uploads/space/2012/1030/193028_MGjl_102055.png" alt="" border="0" height="455" width="600" /><br /> </p><p style="line-height:16px;text-indent:nullem;text-align:left">&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;点击Executu Query查询，右侧生成了地址可以打开查看，到此结束。</p></div><br /><div>原文地址：<a href="http://insolr.com/forum.php?mod=viewthread&amp;tid=880&amp;page=1&amp;extra=#pid969" target="_blank">http://insolr.com/forum.php?mod=viewthread&amp;tid=880&amp;page=1&amp;extra=#pid969</a></div><img src ="http://www.blogjava.net/xiaohuzi2008/aggbug/392373.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/xiaohuzi2008/" target="_blank">小胡子</a> 2012-12-03 16:48 <a href="http://www.blogjava.net/xiaohuzi2008/archive/2012/12/03/392373.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>