SOLR deployment and configuration

Solr is usually deployed in two ways. One is to deploy in an external web container such as tomcat, and the other is to use Solr’s built-in jetty as a web container.
Here we use the built-in jetty as the deployment method of the web container.

1.Download solr

Download solr
The version of solr used this time is 6.6.0
After downloading, find a suitable location and unzip

2. Start solr

Open the cmd window and enter the bin folder of the solr decompression directory to execute

solr start -p 8983 

start solr

At this time, we can access the solr management interface in the browser
solr management interface

3. Create a core

  • Method 1
    By looking at the README file in the solr root directory, I know that it can be used
 solr create -c name

to create a core

create core

According to the feedback of the above command, you can get some useful information
1. Each core needs a core instance directory
2. You can use Solr’s rest interface to achieve core creation

< p>At this time, we refresh the next management interface and you can see
created successfully

  • Method two
    Use solr management page to create
    1. In Create a folder under the solr.home directory with the same name as core
      View solr .home

Here we create core3

create core3

2. Copy the configuration file to core3
The configsets file in the figure above stores the basic configuration file.
We put the conf under basic_configs in the configsets Copy to core3

image.png

Then create a new folder data in core3 as the storage file for index data

core3

  1. Create a core
    In the solr management page, click add core under core admin, modify the name and instanceDir to core3, and then click add core

image.png

  1. Create complete
    After clicking Finish, there will be an additional core3 in core admin
    Create complete

There are also more folders under core3 A core.properties file

core.properties

The content is

# Written by CorePropertiesLocator#Fri Sep 15< /span> 03:34:37 UTC 2017name=core3config=solrconfig .xmlschema=schema. span>xmldataDir=data pre> 
  • Method 3
    We know that we can use the rest interface of Solr to complete the creation of the core through the command feedback of method one.

First complete the method two In the first two steps, name the core core4

  1. Request the solr rest interface
http://localhost:8983/solr/admin/cores?action=< span class="hljs-constant">CREATE&name=core4&instanceDir=core4

request result

  1. Created successfully

success

4. Import data

The module responsible for importing data in Solr is called DataImportHandler, which has multiple implementation methods.
-Import from database
Solr supports multiple forms of data import , The most commonly used is to import data from the database.
We can find the relevant configuration of importing data from the database from the /example/example-DIH/solr/db/conf that comes with solr as a reference, and then modify the configuration in core1

  1. Modify solrconfig.xml
    Add the following configuration
<requestHandler name="/dataimport" class="solr.DataImportHandler"> <lst name="defaults"> <str name="config">db-data-config.xml str> lst>  requestHandler>
  1. Copy from example db-data-config.xml to core1 and modify it according to the usage of the database. I am using mysql here
<dataConfig> <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test" user="root" password="123456" /> <document> <entity name="item" query="select * from showentity"> <field column="description" name="description" /> <field  column="title" name=" title" /> <field column< /span>="createTime" name="createTime" /> <field span> column="type" name ="type" /> entity> document>dataConfig>
  1. Copy the mysql database connection jar to the dist file in the solr root directory, and then modify solrconfig. xml, load this jar package, and the jar package related to dataimport
"${solr.install.dir:../../../..}/dist/" regex=". *\.jar" />

loading jar Package

  1. Modify managed-schema to schema.xml and modify it according to the fields imported from the database configured in db-data-config.xml.
"title" type="text_general" indexed ="true" stored="true" required=" true" multiValued="false" /> "description" type="text_general" indexed="true" stored="true" required="true" multiValued= "false" /> "createTime" type="date" indexed="true" stored="true" required="true" multiValued="false"< /span> /> "type" type="string" indexed="true" stored="true" required=< span class="hljs-string">"true" multiValued="false" />
  1. In core admin Select the core you just modified in the options, and then click the reload button to load the configuration just modified above

reload

  1. Start importing data
    Select just Modify the DataImport option under the core, and then click the execute button

Import data

  1. Make a query
    Query in the query option and find the data It has been imported

query

Summary

Ok here, we have completed the solr single-point deployment and simple configuration. Later, we will continue to summarize the deployment of the solr cloud cluster, the description of some solr configuration files, etc.

There are usually two ways to deploy Solr. One is to deploy in an external web container such as tomcat, and the other is to use Solr's built-in jetty as a web container.
Here we use the built-in jetty as the deployment method of the web container.

1.Download solr

Download solr
The version of solr used this time is 6.6.0
After downloading, find a suitable location and unzip

2. Start solr

Open the cmd window and enter the bin folder of the solr decompression directory to execute

solr start -p 8983 

start solr

At this time, we can access the solr management interface in the browser
solr management interface

3. Create a core

  • Method 1
    By looking at the README file in the solr root directory, I know that it can be used
 solr create -c name

to create a core

create core

According to the feedback of the above command You can get some useful information
1. Each core needs a core instance directory
2. You can use Solr's rest interface to achieve core creation

At this time, we refresh the next management You can see the interface
Created successfully

  • Method 2
    Use the solr management page to create
    1. Create a folder in the solr.home directory , The same name as core
      View solr.home

Here we create core3

create core3

2. Copy the configuration file to core3
The configsets file in the above figure stores the basic configuration file
We copy the conf under basic_configs in configsets to core3

< p>image.png

Then create a new folder data in core3 as the storage file for index data

core3

  1. Create core
    In the solr management page, click add core under core admin, modify the name and instanceDir to core3, and then click add core

image.png

  1. Creation is complete
    After clicking Finish, there will be an additional core3 in core admin.
     Created

There is also an extra core.properties file under the core3 folder< /p>

core.properties

The content is

#Written by CorePropertiesLocator#Fri Sep 15 03:34:37 UTC 2017name=core3config=solrconfig.xml< /span>schema=schema.xml dataDir=data
  • Method Three
    One method We know that we can use Solr's rest interface to complete the creation of the core

First, complete the first two steps of method two and name the core core4

  1. Request solr rest interface
http://localhost:8983/solr/admin/cores?action=CREATE&name=core4&instanceDir =core4

request result

  1. Create Successfully built

successful

4. Import data

The module responsible for importing data in solr is called DataImportHandler , It has a variety of implementation methods
-Import from a database
Solr supports multiple forms of data import, the most commonly used is to import data from a database
We can import data from solr's own /example/example- Find the relevant configuration of importing data from the database in DIH/solr/db/conf as a reference, and then modify the configuration in core1

  1. Modify solrconfig.xml
    Add the following configuration
  2. < /ol>

    <requestHandler name="/dataimport" class="solr. DataImportHandler"> <lst name="defaults"> <str name="config" >db-data-config.xmlstr> lst> requestHandler>
    1. Copy db-data-config.xml from the example to core1, and modify it according to the usage of the database. What I use here is mysql
    <dataConfig> <dataSource driver= "com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/ test" user="root" password ="123456" /> <document > <entity name="item" span> query="select * from showentity"> <field column="description" span> name="description" /> <field column="title" name="title" /> < field column="createTime" name="createTime" /> <field column="type" name="type" /> entity> document>dataConfig>
    1. Copy the mysql database connection jar to the dist file in the solr root directory, then modify solrconfig.xml, load this jar package, and the jar package related to dataimport
    "${solr.install.dir:../../../..}/dist/" regex=".*\.jar" />

    loading jar package

    1. Modify managed-schema to schema.xml and modify it according to the fields imported from the database configured in db-data-config.xml.
    "title" type ="text_general" indexed="true" stored=" true" required="true" multiValued="false" /> "description" type="text_general" indexed="true" stored="true" required= "true" multiValued="false" /> "createTime" < span class="hljs-keyword">type="date" indexed="true" stored="true" required="true"  multiValued="false" /> "type" type="string" indexed="true" stored= "true" required="true" multiValued="false " />
    1. Select the core you just modified in the core admin option, and then click the reload button to load the configuration you just modified

    reload

    1. Start importing data
      Select the DataImport option under the core you just modified, and then click the execute button

    import data

    1. Make a query
      In the query option, you find that the data has been imported.

    query

    Summary

    ok here is the completion of the single-point deployment and simple configuration of solr, and I will continue to summarize solr later Cloud cluster deployment, descriptions of some solr configuration files, etc.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4579 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.