SOLR Notes (i)

Source: Internet
Author: User
Tags commit solr tomcat
Introduction

SOLR is a stand-alone enterprise Search application server that provides API interfaces similar to Web-service.

The user can submit a certain format XML or JSON file to the SOLR server through the POST request of HTTP, and after the SOLR server parses the file, the index library is deleted and changed according to the specific requirements.

The user can send a search request to the SOLR server via HTTP GET request and get the return result in Xml/json format.

SOLR is a top-level open source project under Apache, developed in Java and based on Lucene. SOLR can run independently in these servlet containers such as jetty (Java-Developed, lightweight), Tomcat, and so on.

SOLR provides a richer query language than Lucene, while it is configurable, extensible, and optimized for indexing and search performance.
SOLR and Lucene differences Lucene is an open-source full-Text Search engine toolkit, which is not a full-text search application. Lucene only provides a complete query engine and indexing engine to provide software developers with an easy-to-use toolkit to facilitate full-text retrieval in target systems, or to build full-text retrieval applications based on Lucene.

SOLR's goal is to create an enterprise-class search engine system, which is based on Lucene a search engine server, 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.

The SOLR Catalogue is detailed

BIN:SOLR Run script CONTRIB:SOLR extension jar package to enhance the functionality of SOLR dist: This directory contains the war and jar files generated during the build process, and the associated dependent file DOCS:SOLR API files

Examples of the EXAMPLE:SOLR project catalog:

L EXAMPLE/SOLR:

The directory is a standard solrhome that contains a default Solrcore

L Example/multicore:

This directory contains multiple core directories that are set up in Solr's multicore.

L 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
The solrhome and Solrcore Solrhome are the home directories that are run by the SOLR server, which includes multiple solrcore directories solrcore the Collection1 directory. This directory contains configuration files and data files (such as index library files) that are required for search and indexing, and each solrcore can provide a separate search and Indexing Service

Solrcore directory:

The SOLR-4.10.3\EXAMPLE\SOLR folder under the SOLR decompression package is a standard solrhome, just copy it to the specified directory, and the Solrhome has a solrcore named Collection1 by default. Configure Solrcore

In fact, is the configuration of the Solrcore directory of Conf/solrconfig.xml.

This file is to configure the relevant run-time information for the Solrcore instance. If you use the default configuration, you do not have to make any modifications . There are many tags in this profile, but we often use tags such as Lib tags, datadir tags, and requesthandler tags. The lib tag lib tag can be configured with some jars of extended functionality to enhance the functionality that SOLR itself does not have.

For example, SOLR itself does not have the "Data Import Index Library" function, if you need to use, you will first copy these jars to the specified directory, and then the configuration file for the relevant configuration
datadir label datadir Data directory. The data directory is used to hold index files and tlog log files.

The requesthandler tag RequestHandler The request processor, which defines how the index and search are accessed.

The index can be added, modified, and deleted by/update Maintenance index.


The index is searched by/select.

Set the search parameters to complete the search, the search parameters can also set some default values, as follows:

<requesthandler name= "/select" class= "SOLR. Searchhandler >
    <!--Set default parameter values, you can modify these parameters in the request address--
    <lst name= "Defaults" >
        <str name= " Echoparams ">explicit</str>
        <int name=" Rows ">10</int><!--Display Quantity-
        <str name= "WT" >json</str><!--display Format--
        <str name= "DF" >text</str><!--default Search field--
    < /lst>	
</requestHandler>

Locate Solr.war, put it under Tomcat WebApps, and then open the config file, Web. config, solrhome in the SOLR package
    <env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>f:\ solr</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    </ Env-entry>

Note that the EXT expansion pack is also imported, with a total of 50 packages. Running Tomcat

Introduction to management interface functions
DashboardDashboard that shows the time, version, system resources, and so on when the SOLR instance starts to run
Logging
SOLR Run log information
Cloud
SOLRCLOUD,SOLR Cloud (Cluster), this menu is displayed when running with SOLR colud mode. Core AdminSOLR Core Management interface, where you can add Solrcore instances, but there are bugs on the browser side, it is not recommended Java PropertiesSolr property information in the JVM runtime environment, CLASSPATH, file encoding ah what. Thead DumpDisplays information about current active threads in SOLR server, as well as tracking line Cheng stacks information. Core SelectorSelect a Solrcore for detailed operation
AnalysisThis interface allows you to test the performance of the index parser and the search analyzer DataImportYou can define a data import processor, import data from a relational database into the SOLR index library, which is not configured by default and requires manual configuration

Document

By/update to update the index, SOLR updates the contents of the document by default based on the ID (unique constraint) field, and if the id field is not searched based on the ID value, the add operation is performed, and if found, the update occurs.

This menu allows you to create indexes, update indexes, delete indexes, and so on, with the following interface:
Overwrite= "true": When SOLR is indexing, replace the document with the XML if it already exists
commitwithin= "1000 ": SOLR does a document submission every 1000 (1 seconds) milliseconds at the time of indexing. To facilitate testing, you can immediately submit,</doc> in document and add "<commit/>"

Query
t to perform the search index through/select, you must specify "Q" Query condition
SOLRJ
What is SOLRJ SOLRJ is a Java client that accesses the SOLR service, providing an API method for indexing and searching

public class Createindextest {
	//SOLR server's underlying URL path
	private String BaseURL = "http://localhost:8080/solr/";
	The Httpsolrserver object that is responsible for interacting with the remote SOLR server
	private Httpsolrserver solrserver = new Httpsolrserver (BaseURL);

	@Test public
	void Testcreateandupdateindex () throws Exception {

		solrinputdocument doc = new Solrinputdocument () ;

		Doc.addfield ("id", "c001");
		Doc.addfield ("Content", "Test SOLRJ Add Operation");
		Call Solrserver API to complete the index library additions and deletions to change the operation
		Solrserver.add (DOC);

		Submit
		Solrserver.commit ();
	}

	@Test public
	void Testdeleteindex () throws Exception {
		//deleted by ID
		//Solrserver.deletebyid ("c001");

		Delete
		solrserver.deletebyquery ("Id:change.me") based on the query object;

		Delete all
		solrserver.deletebyquery ("*:*");

		Submit
		Solrserver.commit ();
	}
}


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.