Lucene's SOLR installation and configuration (vi)

Source: Internet
Author: User
Tags solr zip tomcat tomcat server
First, Introduction1.1 The features we need to implement use SOLR to search for product information in e-commerce websites, search for product information by keyword, category, price, or sort by price. 1.2 Implementation methods in some large-scale portal sites, e-commerce sites, such as the need for site search function, the use of traditional database query method to achieve a search can not meet some advanced search requirements, such as: Fast Search, search results by relevance, search content format is not fixed, etc. This requires the use of full-text retrieval technology to implement the search function. 1.2.1 is implemented using Lucene
Using Lucene alone to achieve intra-station search needs to be developed, mainly in: index maintenance, index performance optimization, search performance optimization, etc., so it is not recommended.
The 1.2.2 is implemented using SOLR
Based on SOLR, in-Site search extensibility is good and can reduce the workload of programmers, because SOLR provides a more complete search engine solution, so in the portal, Forum and other systems commonly used in this scenario. ii. what is SOLRSOLR is a top-level open source project under Apache with Java development, which is a lucene-based full-text Search server. SOLR provides a richer query language than Lucene, while it is configurable, extensible, and optimized for indexing and search performance. SOLR can run independently, running in these servlet containers such as jetty, Tomcat, the implementation of the SOLR index is very simple, with the POST method to the SOLR server to send a description of the Field and its contents of the XML document, SOLR based on the XML document added, deleted, Update the index. The SOLR search only needs to send an HTTP GET request and then parse the query results in the format of SOLR return XML, JSON, and organize the page layout. SOLR does not provide the ability to build the UI, and SOLR provides an administrative interface through which you can query the configuration and operation of SOLR. The difference between 2.1 Solr and Lucene:
Lucene is an open source full-Text Search engine toolkit, which is not a full-text search engine, and Lucene provides a complete query engine and indexing engine to provide software developers with an easy-to-use toolkit to facilitate full-text retrieval in the target system. Or build a full-text search engine based on Lucene. SOLR's goal is to create an enterprise-class search engine system, which is a search engine service, can run independently, through SOLR can very quickly build enterprise's search engine, through SOLR can also be efficient to complete the site search function.

iii.. SOLR Installation and ConfigurationSOLR is a full-text search engine system that can be run independently by deploying to Tomcat, providing full-text search services via the HTTP protocol, which is the index and document additions and deletions service. SOLR directly operates the index library and the document library, our business system can use SOLRJ (SOLR client, is a bunch of jar package) to invoke the SOLR server, let SOLR server Operation document Library and index library, complete the task of adding and deletions, return the result to the SOLRJ client, We can get the result in the business system and then return it to the customer to display in the browser.
3.1. SOLR downloads from SOLR official website (http://lucene.apache.org/solr/ Download Solr4.10.3, under the operating environment of SOLR, Linux needs to download lucene-4.10.3.tgz,windows under Download Lucene-4.10.3.zip. The SOLR User Guide can be consulted at: Https://wiki.apache.org/solr/FrontPage.
3.2. SOLR's folder structure
Unzip the Solr-4.10.3.zip:

Run scripts for BIN:SOLR
Some of the CONTRIB:SOLR software/plugins are used to enhance SOLR's functionality.
Dist: This directory contains the war and jar files that were generated during the build process, as well as related dependent files.
API documentation for DOCS:SOLR
Examples of the EXAMPLE:SOLR project catalog:
(1) EXAMPLE/SOLR:
The directory is a core directory of SOLR that contains the default configuration information.
(2) Example/multicore:
This directory contains multiple core directories that are set up in Solr's multicore.
(3) Example/webapps:
The directory includes a Solr.war, which can be used as a running instance project for SOLR.
Some licensing information related to LICENSES:SOLR
3.3 Operating Environment
SOLR needs to run in a servlet container, Solr4.10.3 requires JDK usage above 1.7, SOLR provides jetty (Java-written servlet container), this tutorial uses Tocmat as the servlet container, the environment is as follows:
solr:solr4.10.3
jdk:jdk1.7.0_72
tomcat:apache-tomcat-7.0.53
3.4 Solr consolidates Tomcat
3.4.1 SOLR Home and Solrcore
Create a SOLR home directory, Solrhome is the home directory that SOLR runs, including the configuration files and data files running the SOLR instance, the SOLR instance is Solrcore, A solrhome can include multiple Solrcore (SOLR instances), each solrcore providing a separate search and Indexing Service.
Solrhome:solrhome is the most core directory of SOLR, and there can be more than one SOLR instance in a solrhome.
Solrcore: A solrcore is a SOLR instance, and their index libraries and document libraries are isolated from each other between instances and instances in SOLR. Each instance provides separate index and document additions and deletions to the service, and the default instance is called Collection1.
For example: (1) EXAMPLE\SOLR is a SOLR home directory structure, as follows:

In the image above, "Collection1" is a solrcore (SOLR instance) directory, the contents of which are as follows:

Description
Collection1: Called a SOLR Run instance Solrcore,solrcore name is not fixed, a SOLR run instance provides an index and a search interface separately from the outside. Multiple SOLR Run instance Solrcore can be created in Solrhome. A running instance of SOLR corresponds to an index directory. Conf is the configuration file directory for Solrcore. The data directory that holds the index file needs to be created.
3.4.2 Integration Steps
Because we want to deploy SOLR independently on a tomcat server, with our application not on a server. So I copied a copy of the Tomcat I used in eclipse and used it for SOLR alone.
The first tomcat is used for the application, and the second tomcat is used for SOLR. We modified the second Tomcat configuration file Server.xml as follows:
<connector connectiontimeout= "20000" port= "8181" protocol= "http/1.1" redirectport= "8443"/>
First step: Install Tomcat. D:\DevelopApp\Tomcat\apache-tomcat-7.0.61-solr
Step two: Copy the Solr War package into Tomcat's WebApp directory. Copy the \solr-4.10.3\dist\solr-4.10.3.war to the D:\DevelopApp\Tomcat\apache-tomcat-7.0.61-solr\webapps. renamed to Solr.war
Step three: Solr.war decompression. Use the compression tool to unzip or start the Tomcat automatic decompression. Remove Solr.war after decompression
Fourth step: Add all the jar packages under the \solr-4.10.3\example\lib\ext directory to the SOLR project.
Fifth step: Configure Solrhome and Solrcore. (1) Create a solrhome (a folder that holds all of SOLR's configuration files). The \SOLR-4.10.3\EXAMPLE\SOLR directory is a standard solrhome.
(2) Copy the \SOLR-4.10.3\EXAMPLE\SOLR folder to the E:\temp path, renamed to Solrhome, renaming is not necessary, is to facilitate understanding.
(3) Under Solrhome There is a folder called Collection1 which is a solrcore. is an example of SOLR. A solrcore is equivalent to a database in MySQL. Solrcore are isolated from each other.
I. There is a folder called Conf in Solrcore that contains the configuration information for the index SOLR instance.
II. There is a solrconfig.xml under the Conf folder. Configures information about the instance. If you use the default configuration, you do not have to make any modifications. Configuration information FOR XML:
The LIB:SOLR service relies on the expansion pack, the default path is the Collection1\lib folder, and if not, create one.
DataDir: The storage path of the index library is configured. The default path is the Collection1\data folder, which is created automatically if there is no Data folder.
RequestHandler:
Sixth step: Tell the SOLR server configuration file about the location of the solrhome. Modify Web. Xml to tell the SOLR server how to use Jndi. The solr/home name must be fixed.
Seventh Step: Start Tomcat
Eighth Step: Visit http://localhost:8181/solr/



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: info-contact@alibabacloud.com 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.