Environment: JDK 1.7 Solr 5.3.0 Tomcat 7 mmseg4j-solr-2.3.0
1. SOLR Environment Construction
1. Unzip the SOLR 5.3.0
2. Create a new Solr_home and copy the Server/solr folder from the extracted file to the Solr_home
3. Configure Solr_home. Create a new application in SOLR_HOME/SOLR MYSOLR
4. Copy the Conf folder in Solr_home/solr/configsets/sample_techproducts_configs to MYSOLR
5. New core.properties content in the MYSOLR directory is NAME=MYSOLR (MYSOLR app in SOLR)
6. Using Tomcat 7 as the SOLR container, unzip the Tomcat
7. Copy the Solr-webapp in Solr-5.3.0\server to the WebApps directory of Tomcat and rename it to SOLR
8. Copying files
(1) Copy the following to the Tomcat/webapps/solr/web-inf/lib folder
(2) Copy the log4j.properties to the Tomcat/webapps/solr/web-inf/classes folder (new classes)
9. Configure Web. XML in the SOLR project, open the Env-entry node, configure the Solr_home
10. Launch Tomcat Browser input HTTP://LOCALHOST:8080/SOLR
11. Select the application, test word breaker, default word breaker for the MYSOLR that you just built in solr_home. Not good for Chinese support
Second, the configuration Chinese word breaker (mmseg4j)
mmseg4j-solr-2.3.0 Support solr5.3
1. Test two jar packages into lib files in the SOLR project in Tomcat
2. Configure the schema.xml of the MYSOLR domain in Solr_home
New:
<fieldtype name= "Textcomplex" class= "SOLR. TextField "positionincrementgap=" "><analyzer><tokenizer class=" Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory "mode=" complex "dicpath=" dic "/></analyzer></fieldtype ><fieldtype name= "Textmaxword" class= "SOLR. TextField "positionincrementgap=" "><analyzer><tokenizer class=" Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory "mode=" Max-word "/></analyzer></fieldtype>< FieldType name= "Textsimple" class= "SOLR. TextField "positionincrementgap=" "><analyzer><tokenizer class=" Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory "mode=" simple "dicpath=" N:/custom/path/to/my_dic "/></ Analyzer></fieldtype>
3. Restart the Tomcat test participle: (Select the textmaxword you just defined)
Third, Java calls SOLR 5.3
Package Myjava.cn.dx.solr;import Org.apache.solr.client.solrj.*;import Org.apache.solr.client.solrj.impl.httpsolrclient;import Org.apache.solr.client.solrj.response.QueryResponse; Import Org.apache.solr.common.solrdocument;import Org.apache.solr.common.solrdocumentlist;import Org.apache.solr.common.solrinputdocument;import Java.io.ioexception;import Java.util.arraylist;import java.util.list;/** * SOLR 5.3.0 * Created by Daxiong on 2015/10/23. */public class MYSOLR {//SOLR URL public static final String URL = "HTTP://LOCALHOST:8080/SOLR"; SOLR applies public static final String SERVER = "MYSOLR"; To index, query field public static string[] Docs = {"SOLR is a stand-alone enterprise Search Application Server", "it provides external similar to Web-servi Ce API "," The user can request "through HTTP," to the search engine server to submit a certain format of the XML file generation cable "," can also be made through an HTTP get operation to find the request "," and get the return result in XML format "}; public static SolrclieNT Getsolrclient () {return new Httpsolrclient (url+ "/" +server); }/** * NEW index */public static void CreateIndex () {solrclient client = Getsolrclient (); int i = 0; list<solrinputdocument> docList = new arraylist<solrinputdocument> (); for (String str:docs) {solrinputdocument doc = new solrinputdocument (); Doc.addfield ("id", i++); Doc.addfield ("Content_test", str); Doclist.add (DOC); } try {Client.add (docList); Client.commit (); } catch (Solrserverexception e) {e.printstacktrace (); } catch (IOException e) {e.printstacktrace (); } }; /** * * Search */public static void search () {solrclient client = Getsolrclient (); Solrquery query = new Solrquery (); Query.setquery ("Content_test: Search"); Queryresponse response = null; try {response = client.query (query); System.out.println (Response.tostring ()); System.out.println (); Solrdocumentlist docs = Response.getresults (); System.out.println ("Number of documents:" + docs.getnumfound ()); SYSTEM.OUT.PRINTLN ("Query time:" + response.getqtime ()); for (Solrdocument Doc:docs) {System.out.println ("ID:" + doc.getfieldvalue ("id") + "title:" + Doc . GetFieldValue ("Content_test")); }} catch (Solrserverexception e) {e.printstacktrace (); } catch (IOException e) {e.printstacktrace (); }} public static void Main (string[] args) {//createindex (); Search (); }}
Mava Configuration Pom.xml
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > < Modelversion>4.0.0</modelversion> <groupId>myjava</groupId> <artifactid>cn.dx</ artifactid> <version>1.0-SNAPSHOT</version> <packaging>jar</packaging> <name> Cn.dx</name> <url>http://maven.apache.org</url> <properties> < Project.build.sourceencoding>utf-8</project.build.sourceencoding> </properties> <dependencies > <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.solr</groupId> <artifactId>solr-solrj</artifactId> ≪version>5.3.0</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> <d Ependency> <groupId>commons-logging</groupId> <artifactid>commons-logging</artifactid> ; <version>1.1.1</version> </dependency> <dependency> <groupid >org.slf4j</groupId> <artifactId>slf4j-nop</artifactId> <version>1.7.7</version> ; </dependency> </dependencies></project>
SOLR 5.3.0 Integrated mmseg4j, tomcat deployment, SOLRJ 5.3.0 use