Shortly before the development of a project, need to use the SOLR, because so in the beginning to find information on the Internet, but found that most of the information is very one-sided, or just to explain how SOLR installed, or only to explain a certain part of SOLR, and a lot of information is the same, It is difficult to find a person to reprint another person from the SOLR configuration, to connect with the database in the actual project, and because SOLR is developed using Java, most of the real-world instances are Java versions, and the. NET version is few, So it's hard for a. NET developer to learn SOLR without anyone else's explanation, so I'd like to write a series of SOLR tutorials that let a. NET developer without the SOLR foundation see that I can then know the SOLR principle, the important file configuration, the meaning of most parameters, It is also easy to use in. NET projects.
What is SOLR?
So before we learn what is SOLR first look at the official explanation:
SOLR is a stand-alone enterprise Search application server that provides API interfaces similar to Web-service. The user can submit files such as Xml,json, etc., to the Search engine server via HTTP request, generate the index, or make a lookup request via HTTP GET operation, and get the return result of Xml,jsond and other formats, SOLR is a high performance, using JAVA5 development, Lucene-based full-text Search server. At the same time, it is extended to provide a richer query language than Lucene, while it can be configured, extensible and optimized for query performance, and provides a perfect function management interface, is a very good full-text search engine.
Official definition here, this definition of the online pile of a bunch of and are the same, want to know the friends can go to Baidu, basically is a version, so do not waste everyone's time, the following say I understand SOLR:
SOLR is to convert the data of the database through certain index rules into a local file that is easy to retrieve, the suffix of the file is. FDT, and then we go through SOLR to access these local files (which are done internally by SOLR), which speeds up the indexing speed, and SOLR is written in Java, So it needs to run on the Tomcat server, we can access the SOLR in a generic HTTP request, and get the data.
what is SOLR capable of?
SOLR is mainly to achieve big data in the station search, for example, when there is a table with tens of millions of data, there is a field you store is an article, now ask you to find the article content with "blog garden" data, then you how to do, with like query?, that is estimated to find the next day, SOLR can be a good solution to the problem, in the way of SOLR query, up to 1 seconds. The best thing to do is to do it in milliseconds.
In a little digression, SOLR is basically configuring the appropriate files, which is very strange for many. NET programmers, because we are always accustomed to using ready-made, packaged things to use, over time, easy to become lazy, a little trouble to meet the configuration is difficult (this is a lot of. NET Programmer's Common problem I have previously instructed a. NET programmer who wants to learn SOLR online, and he comes up with a word, there is no ready-made example, give me a copy, and then I said no, say this need to configure a lot of XML files in Tomcat, actually with the code is actually very little, Most of SOLR's stuff is in the configuration, and then the programmer almost gives up on SOLR, and after that, it's just a few words to the end of the conversation.
In the first section, we will explain the installation and configuration of SOLR (this basic is the same as everyone else)
Because SOLR is developed in Java and needs to be run in Tomcat (no matter what the project,. NET projects are also deployed in Tomcat, or Nginx), the first step is to install the JDK (jdk1.7 I installed here), with Tomcat ( The choice is TOMCAT7), these two installation is not here to talk about, online a lot of
1. Download Tomcat and SOLR and unzip (install the JDK before installing)
After Tomcat decompression, the disk path is C:/Program Files/apache software foundation/tomcat 7.0 (path arbitrary).
2. Start the Tomcat server
Browser input: http://localhost:8080
This is done in order to generate the Catalina/localhost directory under the tomcat/conf directory, which will be used in the next step.
3. Download SOLR package on the official website i downloaded the solr-4.7.2.
Deploy SOLR to Tomcat
A) Copy the solr-4.7.2 directory EXAMPLE/SOLR to the Tomcat root directory
b) Copy the solr-4.7.2 directory Dist/solr-4.7.2.war to Tomcat Webapps/solr.war (rename);
c) Copy all jars under solr-4.7.2 directory Example/lib/ext to Tomcat, and copy the Log4j.properties file under Example/resources to Tomcat Lib;
d) Create a solr.xml file under Tomcat/conf/catalina/localhost, with the following content:
<?xml version= "1.0" encoding= "Utf-8"? ><context docbase= "Webapps/solr.war" debug= "0" crosscontext= "true" > <environment name= "Solr/home" type= "java.lang.String" value= "C:/Program Files/apache software Foundation /TOMCAT7/SOLR "override=" true "/></context>
4. Restart the Tomcat server, enter HTTP://LOCALHOST:8080/SOLR view service in the browser, the following interface appears to install successfully.
installation IK Word breaker
1.http://code.google.com/p/ik-analyzer/downloads/detail?name=ik%20analyzer%202012ff_hf1.zip&can=2&q=
2. Copy the following IK participle to unpack the following three files below to the Tomcat7\webapps\solr\web-inf\lib\ folder below:
IKAnalyzer.cfg.xml, Ikanalyzer2012ff_u1.jar, Stopword.dic
3. Modify the Schema.xml in the Tomcat7\solr\collection1\conf\ folder. In <types></types>
Add the following content:
<!--Configure the IK word breaker-name is the name below you can select the word breaker--<fieldtype name= "Text_ik" class= "SOLR. TextField "> <!--the word breaker at index time-- <analyzer type=" index "ismaxwordlength=" false "class=" Org.wltea.analyzer.lucene.IKAnalyzer "/> <!--word breaker-- <analyzer type=" Query " Ismaxwordlength= "true" class= "Org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType>
4. Start Tomcat, enter HTTP://LOCALHOST:8080/SOLR in the browser, select Core as Collection1 in the left menu of the page, click the analysis (Funnel shape) menu, and on the right page filed In the Value text box, enter the Chinese string to test the word breaker.
5. Under field value, select Text_ik (my name is TEXT_CN) in analyse Fieldname/fieldtype, then click on the left Analyze value button to see the result of the participle.
As follows:
OK above is SOLR installation, this is only the first step, it still can not do anything, the next section we will explain the SOLR configuration file.
SOLR and. NET Series courses (i) SOLR installation and configuration