Solr installation steps,

Source: Internet
Author: User

Solr installation steps,
I. Solr Overview 1. What is Solr?

Solr is a top-level open-source project under Apache developed using Java. It is a full-text search Server Based on Lucene. Solr provides a richer query language than Lucene, supports configuration and scalability, and optimizes indexing and search performance.

Solr can run independently and run in Jetty, Tomcat, and other Servlet containers. The Solr index implementation method is very simple. The POST method is used to send an XML document describing the Field and its content to the Solr server, solr adds, deletes, and updates indexes based on xml documents. Solr search only needs to send an http get request and parse the query results returned by Solr in Xml, json, and other formats to organize the page layout. Solr does not provide the UI building function. Solr provides a management interface that allows you to query the configuration and running status of Solr.

2. Download

Download e-e-4.10.3.tgzand from Solr official website (

For more information about how to use Solr, see

Download and unzip it:


Bin: solr running script

Contrib: Contribution software/plug-ins of solr to enhance solr functionality.

Dist: This directory contains war and jar files generated during the build process, as well as related dependent files.

Docs: solr API documentation

Example: solr project example directory:

L example/solr:

This directory is a Solr Core directory that contains the default configuration information.

L example/multicore:

This directory contains multiple Core directories set in Solr multicore.

L example/webapps:

This directory contains solr. war, which can be used as a running instance project of solr.

Licenses: Some license information related to solr

Ii. installation and configuration of Solr in Windows 1. Runtime Environment

Solr needs to run in a Servlet container. Solr4.10.3 requires jdk to use more than 1.7. Solr provides Jetty (Servlet container written in java) by default. In this tutorial, Tocmat is used as the Servlet container. The environment is as follows:

Solr: Solr4.10.3

Jdk: jdk1.7.0 _ 72

Tomcat: apache-tomcat-7.0.53

2. Integrate Tomcat with Solr
  • Copy the dist \ solr-4.10.3.war to the webapp directory of Tomcat and rename it solr. war.
  • After tomcat is started, solr. war is automatically decompressed and the original solr. war is deleted.
  • Copy all jar packages under the example \ lib \ ext directory to the Tomcat webapp \ solr \ WEB-INF \ lib directory

  • Copy the log4j. properties File

Create the file classes folder in the webapps \ solr \ WEB-INF directory under Tomcat,

Copy example \ resources \ log4j. properties under the Solr directory to the webapps \ solr \ WEB-INF \ classes directory under Tomcat

  • Create solrhome and configure solrcore's solrconfig. xml file
  • Modify the webapp \ solr \ WEB-INF \ web. xml file in the Tomcat directory, as shown below:

Set Solr home

<! -- Configure jndi to tell solr the location of our solrhome project --> <env-entry-name> solr/home </env-entry-name> <env-entry -value> D: /temp/solr/solrhome </env-entry-value> <env-entry-type> java. lang. string </env-entry-type> </env-entry>
Iii. installation and configuration of Solr in Linux
  • Step 1: install linux, jdk, and tomcat
[root@localhost ~]# lltotal 8044-rw-r--r--. 1 root root 8234674 Oct 27  2013 apache-tomcat-7.0.47.tar.gz[root@localhost ~]# tar -zxf apache-tomcat-7.0.47.tar.gz [root@localhost ~]# lltotal 8048drwxr-xr-x. 9 root root    4096 Sep 10 17:55 apache-tomcat-7.0.47-rw-r--r--. 1 root root 8234674 Oct 27  2013 apache-tomcat-7.0.47.tar.gz[root@localhost ~]# mkdir /usr/local/solr[root@localhost ~]# cp apache-tomcat-7.0.47 /usr/local/solr/tomcatcp: omitting directory `apache-tomcat-7.0.47'[root@localhost ~]# cp apache-tomcat-7.0.47 /usr/local/solr/tomcat -r[root@localhost ~]# cd /usr/local/solr/[root@localhost solr]# lltotal 4drwxr-xr-x. 9 root root 4096 Sep 10 17:56 tomcat[root@localhost solr]#
  • Step 2: Upload the solr compressed package to the server. Decompress the package
  • Step 3: deploy the/root/solr-4.10.3/dist/solr-4.10.3.war package to tomcat. And renamed it solr. war.
[root@localhost dist]# cp solr-4.10.3.war /usr/local/solr/tomcat/webapps/solr.war
  • Step 4: Decompress the war package. Start tomcat to automatically decompress the package. Disable tomcat. Delete solr. war
  • Step 5: Copy all jar packages under the/root/solr-4.10.3/example/lib/ext directory to the solr Project
[root@localhost ext]# cp * /usr/local/solr/tomcat/webapps/solr/WEB-INF/lib/
  • Step 6: Create solrhome. Solrhome is the directory that stores all the configuration files of the solr server.
[root@localhost example]# pwd/root/solr-4.10.3/example[root@localhost example]# cp -r solr /usr/local/solr/solrhome[root@localhost example]#
  • Step 7: Tell the solr server the location of solrhome

You need to modify the web. xml file of the solr project:

  • Step 8: start tomcat



Iv. Solr interface functions

5. Install the Chinese word Divider
  • Step 1: Use IK-Analyzer. Upload the analyzer folder to the server
  • Step 2: add the jar package of the analyzer to the solr project.
[root@localhost IK Analyzer 2012FF_hf1]# cp IKAnalyzer2012FF_u1.jar /usr/local/solr/tomcat/webapps/solr/WEB-INF/lib/[root@localhost IK Analyzer 2012FF_hf1]#
  • Step 3: copy the extended dictionary and deprecated word dictionary and configuration file required by IKAnalyzer to the classpath of the solr project.
/usr/local/solr/tomcat/webapps/solr/WEB-INF/classes[root@localhost IK Analyzer 2012FF_hf1]# cp IKAnalyzer.cfg.xml ext_stopword.dic mydict.dic /usr/local/solr/tomcat/webapps/solr/WEB-INF/classes[root@localhost IK Analyzer 2012FF_hf1]# 

Note: The character set of extended dictionary and deprecated dictionary must be UTF-8. Cannot be edited using windows notepad

  • Step 4: Configure fieldType. It needs to be configured in solrhome/collection1/conf/schema. xml

Tip: Use vi and vim to jump to the beginning of the document gg. Jump to the end of the document: G

<fieldType name="text_ik" class="solr.TextField">    <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/></fieldType>

Vi. Business Field Configuration

Criteria for determining business fields:

1. Do you need to search for this field during search. For example: product name, selling point, product description

2. Do you need this field for future businesses. For example, the product id.

Required fields:

1. Product id

2. Product title

3. selling points

4. Price

5. product images

6. product category name

7. Product Description

It must be configured at the end of solrhome/collection1/conf/schema. xml

<field name="item_title" type="text_ik" indexed="true" stored="true"/><field name="item_sell_point" type="text_ik" indexed="true" stored="true"/><field name="item_price"  type="long" indexed="true" stored="true"/><field name="item_image" type="string" indexed="false" stored="true" /><field name="item_category_name" type="string" indexed="true" stored="true" /><field name="item_desc" type="text_ik" indexed="true" stored="false" /><field name="item_keywords" type="text_ik" indexed="true" stored="false" multiValued="true"/><copyField source="item_title" dest="item_keywords"/><copyField source="item_sell_point" dest="item_keywords"/><copyField source="item_category_name" dest="item_keywords"/><copyField source="item_desc" dest="item_keywords"/>

Restart tomcat


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.