SOLR6 +mmseg4j+ik-analyzer + SQL Server +DIH fully configured

Source: Internet
Author: User
Tags solr

Now there is a search for any system, and the search world has the famous Three musketeers: Solr/elasticsearch/sphinx

Solr/elasticsearch for the same class, are based on the development of Lucene products, I also as early as a few years ago used SOLR to do similar products in Zhongguancun search, faceting function is very useful.

Recently on hand there is another project to build a search, because a few years did not touch SOLR, now once again open official website already feel very strange, not only the homepage for beautiful, version is to 6.1, also has the concept of SOLR cloud!!

Not much nonsense to say, first to introduce the environment configuration:

1. Go to http://www.apache.org/dyn/closer.lua/lucene/solr/6.1.0 download zip, unzip and put in the location you want to put, I put the e-packing directory

2. set the environment variable Path:e:\solr-6.1.0\bin, which is convenient to find the SOLR command directly inside the command line

3. Create a directory at any location that contains the following content

1). Ik+mmseg4j's Dictionary

2). SQL Server JDBC Driver

3). The latest version of the IK+MMSEG4J jar package

Then create a 1.start-solr.cmd (your favorite name) under the directory, with the following content:

SOLR start-h localhost-p 58983-m 1g-s "%~dp0solr_home"-noprompt-v

Double-click to run (if the directory requires administrator privileges, you may need to run it in administrative mode)

Here's the exact configuration.

solrconfig.xml (\solr_home\products\conf\solrconfig.xml)

The profile was put into the core, and I created a new core of products

Configure all the dependent jar packages in

<Libdir= "${solr.install.dir:". /.. /.. /..} /dist/"Regex= "Solr-dataimporthandler-.*\.jar" />   <!--also compatible with Mmseg4j+ik Chinese word breaker -  <Libdir= "${solr.solr.home}/". /tokenizers/mmseg4j "Regex= ". *\.jar" />  <Libdir= "${solr.solr.home}/". /tokenizers/ik-analyzer "Regex= ". *\.jar" />  <Libdir= "${solr.solr.home}/". /sqlserver-jdbc "Regex= ". *\.jar" />

To enable DIH, it is important to note that this feature relies on the Solr-dataimporthandler-xx.jar configuration above

<!--Enable Dih data import -  <RequestHandlername= "/dataimport"class= "SOLR." Dataimporthandler ">    <LSTname= "Defaults">      <Strname= "config">Db-data-config.xml</Str>    </LST>  </RequestHandler>

The following is the SOLR6 inside, if you want to manually modify the Schame.xml configuration to replace, see the comment link

<!---<class= "Classicindexschemafactory" />

Schema.xml Configuration

<!--The following definitions of Chinese word breakers and their respective dictionary configuration -  <FieldTypename= "Mmseg4jcomplex"class= "SOLR." TextField "Positionincrementgap= "+">    <Analyzer>      <Tokenizerclass= "Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"Mode= "complex"Dicpath= "${solr.solr.home:}/". /dict/mmseg4j " />    </Analyzer>  </FieldType>  <FieldTypename= "Mmseg4jmaxword"class= "SOLR." TextField "Positionincrementgap= "+">    <Analyzer>      <Tokenizerclass= "Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"Mode= "Max-word"Dicpath= "${solr.solr.home:}/". /dict/mmseg4j "  />    </Analyzer>  </FieldType>  <FieldTypename= "Mmseg4jsimple"class= "SOLR." TextField "Positionincrementgap= "+">    <Analyzer>      <Tokenizerclass= "Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"Mode= "simple"Dicpath= "${solr.solr.home:}/". /dict/mmseg4j " />    </Analyzer>  </FieldType>  <FieldTypename= "Text_ik"class= "SOLR." TextField ">    <!--the word breaker at index time -    <Analyzertype= "Index">      <Tokenizerclass= "Org.wltea.analyzer.util.IKTokenizerFactory"Usesmart= "true"/>    </Analyzer>    <!--the word breaker when querying -    <Analyzertype= "Query">      <Tokenizerclass= "Org.wltea.analyzer.util.IKTokenizerFactory"Usesmart= "false"/>    </Analyzer>  </FieldType>

Db-data-config.xml

<Dataconfig>  <DataSourcetype= "Jdbcdatasource"Driver= "Com.microsoft.sqlserver.jdbc.SQLServerDriver"URL= "JDBC:SQLSERVER://127.0.0.1:1433;DATABASENAME=XXDB;"User= "Dev"Password= "111111"batchsize= "+" />  <Document>    <Entityname= "Product"Query= "SELECT [Id],[name],[brief],[description] from [Products]"Deltaquery= "SELECT ID from [Products] where [LastModificationTime] > ' ${dataimporter.last_index_time} '">      <Fieldcolumn= "Name"name= "Name" />      <Fieldcolumn= "brief"name= "brief" />      <Fieldcolumn= "description"name= "description" />    </Entity>  </Document></Dataconfig>

The paths contained in the above configuration are not written dead, placeholders used, available placeholders can be seen in the dashboard JVM bar of the SOLR Admin UI

!!!!!!!!!!!!!!!!! HIGH ENERGY!!!!!! ahead Annex Description!!!!!!!!!!

Click I download attachments, double-click Run, if there is an error, you come to spray me ah, it is so simple!

(Be sure to first configure the PATH environment variable and then double-click)

SOLR6 +mmseg4j+ik-analyzer + SQL Server +DIH fully configured

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.