solr 入门 (安装)
非数据库安装
------------------------------------------------------------------------------------------------------------------------------
1.下载 solr
http://mirrors.cnnic.cn/apache/lucene/solr/4.10.4/solr-4.10.4.zip
2.解压solr
拷贝 solr-4.10.4 \dist \solr.war 到tomcat7\webapps\下
solr-xxx .war 改名为solr.war
3.
将 \solr-4.x\example\solr 拷贝到 D:\software\apache-tomcat-7.0.52 \ 下
4.
将\solr-4.10.4\example\lib\ext下的jar包拷贝到\apache-tomcat-7.0.52 \lib下
将\solr-4.10.4\example\resources\log4j.properties 拷贝到\apache-tomcat-7.0.52 \lib 下
5.
在\tomcat-7.x\conf\Catalina\localhost\下建立solr.xml文件,黏贴下面的内容。
<Context docBase="D:\software\apache-tomcat-7.0.52\webapps\solr.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="D:\software\apache-tomcat-7.0.52\solr" override="true" /> </Context>
docBase是第2步war包的路径,下面的value是第3步的目录
6.
数据库安装
------------------------------------------------------------------------------------------------------------------------------
0.修改D:\software\apache-tomcat-7.0.52\conf\Catalina\localhost 下 solr .xml
<Context docBase="D:/software/apache-tomcat-7.0.52/webapps/solr" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="D:/software/mydbsolr" override="true" /> </Context>
1.
将example\example-DIH\solr\ 下的db文件夹放入
D:\software\mydbsolr
2.solr.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <solr sharedLib="lib" persistent="true"> <cores adminPath="/admin/cores"> <core default="true" instanceDir="db" name="db"/> </cores> </solr>
3.在D:\software\mydbsolr\db\lib 中 添加 以下jar包
4.D:\software\mydbsolr\db\conf
下 db-data-config.xml
<dataConfig> <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/fusionweb?useUnicode=true&characterEncoding=utf8" user="root" password="root"/> <document name="content"> <entity name="user" query="select userid,username,userpswd,nickname,contacts,telephone,enterprise,regtime,provinceid,roleid from user"> <field column="userid" name="userid" /> <field column="username" name="username" /> <field column="userpswd" name="userpswd" /> <field column="nickname" name="nickname" /> <field column="contacts" name="contacts" /> <field column="telephone" name="telephone" /> <field column="enterprise" name="enterprise" /> <field column="regtime" name="regtime" /> <field column="provinceid" name="provinceid" /> <field column="roleid" name="roleid" /> </entity> </document> </dataConfig>
下 schema.xml
<?xml version="1.0" encoding="UTF-8" ?> <schema name="user" version="1.5"> <types> <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/> <fieldType name="string" class="solr.StrField" sortMissingLast="true"/> <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/> <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/> <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="solr.StandardTokenizerFactory"/> <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" /> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/> <filter class="solr.LowerCaseFilterFactory"/> </analyzer> </fieldType> <!-- <fieldType name="text" class="solr.TextField"> <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType> --> </types> <fields> <field name="userid" type="string" indexed="true" stored="true" required="true" /> <field name="username" type="string" indexed="true" stored="true" multiValued="false"/> <field name="userpswd" type="string" indexed="true" stored="true" multiValued="false"/> <field name="nickname" type="string" indexed="true" stored="true" multiValued="false"/> <field name="contacts" type="string" indexed="true" stored="true" multiValued="false"/> <field name="telephone" type="string" indexed="true" stored="true" multiValued="false"/> <field name="enterprise" type="string" indexed="true" stored="true" multiValued="false"/> <field name="regtime" type="string" indexed="true" stored="true" multiValued="false"/> <field name="provinceid" type="long" indexed="true" stored="true" multiValued="false"/> <field name="roleid" type="long" indexed="true" stored="true" /> <field name="_version_" type="long" indexed="true" stored="true"/> <field name="text" type="text_general" indexed="true" stored="false" multiValued="true"/> </fields> <uniqueKey>userid</uniqueKey> <!-- <defaultSearchField>contacts</defaultSearchField> <solrQueryParser defaultOperator="OR"/> <copyField source="username" dest="contacts"/> <copyField source="nickname" dest="contacts"/> --> </schema>
下 solrconfig.xml
注释 所有的lib
<!-- 20150529 <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-dataimporthandler-.*\.jar" /> <lib dir="${solr.install.dir:../../../..}/contrib/extraction/lib" regex=".*\.jar" /> <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-cell-\d.*\.jar" /> <lib dir="${solr.install.dir:../../../..}/contrib/clustering/lib/" regex=".*\.jar" /> <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-clustering-\d.*\.jar" /> <lib dir="${solr.install.dir:../../../..}/contrib/langid/lib/" regex=".*\.jar" /> <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-langid-\d.*\.jar" /> <lib dir="${solr.install.dir:../../../..}/contrib/velocity/lib" regex=".*\.jar" /> <lib dir="${solr.install.dir:../../../..}/dist/" regex="solr-velocity-\d.*\.jar" /> -->
捐助开发者
在兴趣的驱动下,写一个免费
的东西,有欣喜,也还有汗水,希望你喜欢我的作品,同时也能支持一下。 当然,有钱捧个钱场(右上角的爱心标志,支持支付宝和PayPal捐助),没钱捧个人场,谢谢各位。
谢谢您的赞助,我会做的更好!