Apache SOLR Analysis

Source: Internet
Author: User
Tags apache solr solr

This article is a companion article about Apache SOLR. I will analyze each package of Apache SOLR one by one, and try to analyze the SOLR design and architecture in detail. Apache SOLR consists of 12 packages:

  1. Org. Apache. SOLR. Analysis
  2. Org. Apache. SOLR. Core
  3. Org. Apache. SOLR. Request
  4. Org. Apache. SOLR. Schema
  5. Org. Apache. SOLR. Search
  6. Org. Apache. SOLR. Search. Function
  7. Org. Apache. SOLR. servlet
  8. Org. Apache. SOLR. TST
  9. Org. Apache. SOLR. Update
  10. Org. Apache. SOLR. util
  11. Org. Apache. SOLR. util. Test
  12. Org.apache.solr.util.xls t

Apache SOLR is still in development, and the current version is 1.1.0. There are very few annotations in the document. From the user's point of view, the first thing we can see is servlet, because SOLR itself is an independent network application and needs to be run in the servlet container to provide services, therefore, servlet is the outermost layer exposed to users.

Let's take a look at the org. Apache. SOLR. servlet package. This package is very simple and has only two classes: solrservlet and solrupdateservlet. We can easily guess the usage of these two classes from the class name.

The solrservlet class inherits the httpservlet class and has only four methods:

  • Init ()
  • Destroy ()
  • Doget ()
  • Dopost ()

In addition to common Java class objects (including servlet-related objects), solrservlet classes have four SOLR classes and a SOLR exception. Two of the classes and one exception belong to the org. Apache. SOLR. core package, and the two classes belong to the org. Apache. SOLR. Request package. Core packages include:

  1. Config:
  2. Solrcore:

The request packages include:

  1. Solrqueryresponse:
  2. Queryresponsewriter:

Analyze the solrservlet class.
First, Servlet will call the init () method for initialization: Use context to find Java: COMP/ENV/SOLR/home to determine the SOLR home directory (home), and then call config. setinstancedir (home) method to set the directory of this instance. Then, a solrcore instance is obtained through solrcore. getsolrcore.
The destroy () method is called when the servlet object is destroyed, and only the core. Close () method is called to close the solrcore instance.
When a user requests in, dopost () simply submits the task to doget () for completion, and the main task is completed by doget.
Analyze the doget () method:

  1. Use the solrcore and doget () parameters to generate a solrservletrequest object (Note: This solrservletrequest class is not a public class and is located at Org. apache. SOLR. the servlet package inherits the solrqueryrequestbase class and only accepts solrcore and httpservletrequest objects as parameters)
  2. Then solrcore executes the execute () method (the parameters are solrservletrequest and solrqueryresponse)

It can be seen that the true processing core is the solrcore execute method. In the next article, we will continue our analysis.

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.