Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure the Solr environment

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "how to configure the Solr environment", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "how to configure the Solr environment" this article.

1. Configure solr environment

1. Download solr http://www.apache.org/dyn/closer.cgi/lucene/solr/

Here we use 4.6decompress to D disk D: / solr/apache-solr-4.6.0

2. Modify tomcat conf/server.xml

Add coded configuration URIEncoding= "UTF-8" (if not, Chinese search cannot be done because of garbled code)

3. Configure solr

Add solr.xml under Tomcat conf/Catalina/localhost

Content:

4. Start tomcat and enter http://localhost:8080/solr/ to show that the welcome screen is successful

II. Configuration of Chinese word segmentation

1. Download the word splitter: http://code.google.com/p/mmseg4j/

2. Download thesaurus: http://code.google.com/p/mmseg4j/downloads/detail?name=data.zip&can=2&q

3. Copy the mmseg4j-all-1.8.5.jar under the extracted mmseg4j-1.8.5 directory to the webapps/solr/WEB-INF/lib directory of Tomcat.

4. Add a thesaurus: create a new dic folder under the D:/solr/apache-solr-4.6.0/example/solr directory, and copy the words.dic under the extracted data directory to the D:/solr/apache-solr-4.6.0/example/solr/dic directory.

5. Change the schema.xml (D:/solr/apache-solr-4.6.0/example/solr/conf/) file to make the word splitter work.

The following configurations are added in the, and sections of schema.xml:

Note: dicPath= "" is your thesaurus path.

Restart your tomcat.

Visit: http://localhost:8080/solr/admin/analysis.jsp can see the word segmentation effect of mmseg4j. Select name from the drop-down menu of Field, and then enter complex in the application. The result of participle, as shown in the following figure:

All right, it's ready to run, so add a document and create a mmseg4j-solr-demo-doc.xml document in the extracted D:/solr/apache-solr-4.6.0/example/exampledocs directory, as follows:

one

Efficient and flexible caching function, vertical search function.

two

Solr is a high-performance full-text search server developed with Java5 and based on Lucene.

three

Independent enterprise search application server

Note: the field name used must be added in solr's configuration file schem.xml

Same as under (id, title)

Then run post.jar under cmd, as follows:

D:\ solr\ apache-solr-4.6.0\ example\ exampledocs > java-Durl= http://localhost:8080/

Solr/update-Dcommit=yes-jar post.jar mmseg4j-solr-demo-doc.xml

Note: mmseg4j-solr-demo-doc.xml is in UTF-8 format, otherwise it will be garbled after submission. And when querying Chinese, you need to set tomcat to URIEncoding= "UTF-8".

To see if there is any data, visit: http://localhost:8080/solr/admin/ enter "High performance" in Query String:

The display is as shown in the following figure:

3. Solr turns the database into an index data source (take mysql as an example)

1. Configure the import data function in solrconfig.xml (under D:\ solr\ apache-solr-4.6.0\ example\ solr\ conf)

D:\ solr\ apache-solr-4.6.0\ example\ solr\ conf\ db\ db-data-config.xml

2. Add a data source db-data-config.xml (under D:\ solr\ apache-solr-4.6.0\ example\ solr\ conf\ db)

CREATE TABLE t_user

(

Id VARCHAR (255) PRIMARY KEY

Name VARCHAR (10) NOT NULL

Title VARCHAR (10)

);

3. Put the mysql driver package (under the webapps/solr/WEB-INF/lib directory of Tomcat)

4. Create an index

Http://localhost:8080/solr/dataimport?command=full-import

5. Check whether it is successful. Visit: http://localhost:8080/solr/admin/, enter "sunshan" and "Sun Shun" in Query String:

As shown below:

Note: ensure a correct connection to the database

IV. Solr multicore (MultiCore) configuration

1. Copy core0, core1 and exampledocs under multicore (D:\ solr\ apache-solr-4.6.0\ example) to solr (under D:\ solr\ apache-solr-4.6.0\ example\ solr).

2. Change the solr.xml configuration (under D:\ solr\ apache-solr-4.6.0\ example\ solr)

Add:

After configuration:

3. Start tomcat access:

Http://localhost:8080/solr/

5. Multicore database index:

Same configuration as above

Note: error Error loading class' org.apache.solr.handler.dataimport.DataImportHandler' occurred

Need to be configured (in solrconfig.xml)

Dir pay attention to path

Restart tomcat

Create an index: http://localhost:8080/solr/core1/dataimport?command=full-import

Http://localhost:8080/solr/dataimport?command=full-import this url tells solr to do a full index, and all data will be deleted in the index. Of course, you can also use the clean=false parameter to tell it not to delete, but it will also delete the same id (declared in the uniqueKey of scheam.xml). Http://localhost:8080/solr/dataimport?command=full-import&clean=false

Bulk import command=delta-import&commit=y

Reload the configuration file command=reload-config

Terminate the import of command=abort

These are all the contents of the article "how to configure the Solr Environment". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report