SOLR 5.2.1 Deploying and indexing the MySQL database

Source: Internet
Author: User
Tags solr

1.SOLR Introduction

SOLR is a high performance, JAVA5 developed, SOLRSOLR full-text Search server based on Lucene. 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.

SOLR not only can be used for various documents (DOC, TXT, PDF, html ... ), and you can index the data in the database.

SOLR 5.2.1:HTTP://ARCHIVE.APACHE.ORG/DIST/LUCENE/SOLR/5.2.1/

2. Start SOLR

  Unzip the SOLR file to any directory, CD to SOLR home directory:/solr-5.2.1, start SOLR with the following command

BIN\SOLR start

Open the HTTP://LOCALHOST:8983/SOLR and enter the SOLR management interface;

3.CREATE Solrcore

Create a new Solrcore, named Collection, with the following command:

BIN\SOLR create-c Collection

The system will automatically generate the collection directory located at: \solr-5.2.1\server\solr\collection;

4. Modify the relevant configuration file

  4.1 Open Collection\conf\solrconfig.xml and add the following:

 <RequestHandlername= "/dataimport"class= "SOLR." Dataimporthandler ">    <LSTname= "Defaults">      <Strname= "config">Data-config.xml</Str>    </LST>  </RequestHandler>

Then find the following:

  <schemafactoryclass= "Managedindexschemafactory">    <BOOLname= "mutable">True</BOOL>    <Strname= "Managedschemaresourcename">Managed-schema</Str>  </schemafactory>

Modified to:

  <class= "managedindexschemafactory"/>

  4.2 Create the Data-config.xml file under the current directory, as follows:

<?XML version= "1.0" encoding= "Utf-8"?>  <Dataconfig>    <DataSourcename= "Slave1"type= "Jdbcdatasource"Driver= "Com.mysql.jdbc.Driver"URL= "jdbc:mysql://your_ip: 3306/your_database_name"User= "username"Password= "password"batchsize= "-1" />                 <Document>        <Entityname= "Weibo"PK= "ID"DataSource= "Slave1"Query= "Select Id,text,baseurl,author from your_table_name">           <Fieldcolumn= "id"name= "id" />          <Fieldcolumn= "text"name= "text" />          <Fieldcolumn= "BaseUrl"name= "BaseUrl" />          <Fieldcolumn= "Author"name= "Author" />        </Entity>    </Document> </Dataconfig>

 4.3 in the current directory to create admin-extra.html, admin-extra.menu-bottom.html, admin-extra.menu-top.html three files;

 4.4 Renaming the Managed-schema file to Schema.xml

After opening, add the following:

<Fieldname= "text"type= "Text_ikanalyzer"indexed= "true"stored= "true" />     <Fieldname= "BaseUrl"type= "Text_general"indexed= "true"stored= "true" />     <Fieldname= "Author"type= "Text_general"indexed= "true"stored= "true" />     <Defaultsearchfield>Text</Defaultsearchfield><FieldTypename= "Text_ikanalyzer"class= "SOLR." TextField ">      <Analyzertype= "Index"Ismaxwordlength= "true"class= "Org.wltea.analyzer.lucene.IKAnalyzer"/>       <Analyzertype= "Query"Ismaxwordlength= "true"class= "Org.wltea.analyzer.lucene.IKAnalyzer"/>     </FieldType>

4.5 The relevant jar packages into the \solr-5.2.1\server\solr-webapp\webapp\web-inf\lib directory, including:

\solr-5.2.1\ Solr-dataimporthandler-5.2.1.jar and SOLR-DATAIMPORTHANDLER-EXTRAS-5.2.1.JARJDBC drivers in the Dist directory: Mysql-connector-java-5.0.8-bin.jar Ik-analyzer Word breaker: Ik-analyzer-forsolr5.1.jar

4.6 Ik-analyzer The relevant configuration file into the \solr-5.2.1\server\solr-webapp\webapp\web-inf\classes directory (no new one)

4.7 re-start SOLR

8983

4.8 Importing database data

    • Open HTTP://LOCALHOST:8983/SOLR;
    • Select collection;
    • Click DataImport;
    • excute,done!

The PS:SOLR Delete Index command is:

< Delete >< Query >*:*</query></Delete><  commit/>

SOLR 5.2.1 Deploying and indexing the MySQL database

Related Article

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.