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
At this time, we can access the solr management interface in the browser
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
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
- Method two
Use solr management page to create
- In Create a folder under the solr.home directory with the same name as core
- In Create a folder under the solr.home directory with the same name as core
Here we 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
Then create a new folder data in core3 as the storage file for index data
- 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
p>
- Create complete
After clicking Finish, there will be an additional core3 in core admin
There are also more folders under core3 A core.properties file
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
- Request the solr rest interface
http://localhost:8983/solr/admin/cores?action=< span class="hljs-constant">CREATE&name=core4&instanceDir=core4
- Created successfully
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
- 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>
- 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" /> span> <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>
- 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" />
- 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" />
- 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
- Start importing data
Select just Modify the DataImport option under the core, and then click the execute button
- Make a query
Query in the query option and find the data It has been imported
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
At this time, we can access the solr management interface in the browser
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
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
- Method 2
Use the solr management page to create
- Create a folder in the solr.home directory , The same name as core
- Create a folder in the solr.home directory , The same name as core
Here we 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>
Then create a new folder data in core3 as the storage file for index data
- 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
- Creation is complete
After clicking Finish, there will be an additional core3 in core admin.
There is also an extra core.properties file under the core3 folder< /p>
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
- Request solr rest interface
http://localhost:8983/solr/admin/cores?action=CREATE&name=core4&instanceDir =core4
- Create Successfully built
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
- Modify solrconfig.xml
Add the following configuration - 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
- 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
- Modify managed-schema to schema.xml and modify it according to the fields imported from the database configured in db-data-config.xml. li>
- Select the core you just modified in the core admin option, and then click the reload button to load the configuration you just modified
- Start importing data
Select the DataImport option under the core you just modified, and then click the execute button - Make a query
In the query option, you find that the data has been imported.
< /ol>
<requestHandler name span>="/dataimport" class="solr. DataImportHandler"> <lst name="defaults"> <str name="config" >db-data-config.xmlstr> lst> requestHandler>
<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>
"${solr.install.dir:../../../..} span>/dist/" regex=".*\.jar" />
"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 " />
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.