话不多说直接上图
1.官方网址:https://lucene.apache.org/solr/
2修改配置文件。
关方示例
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">/path/to/my/DIHconfigfile.xml</str>
</lst>
</requestHandler>
3在conf目录下新建对应的文件
数据库配置
<?xml version="1.0" encoding="UTF-8" ?> <dataConfig> <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://192.168.100.8:3306/youban" user="youban" password="youbanhome_123456" /> <document name="healthyDoc"> <entity name="healthy" query="select * FROM yb_healthy_result "> <field column="result_id" name="id" /> <field column="result_id" name="name" /> <field column="result_memo" name="content" /> </entity> </document> </dataConfig>
4 修改这个文件
在这个文件的最后加上
<!-- ChineseAnalyzer --> <fieldType name="solr_cnAnalyzer" class="solr.TextField" positionIncrementGap="100"> <analyzer type="index"> <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/> </analyzer> <analyzer type="query"> <tokenizer class="org.apache.lucene.analysis.cn.smart.HMMChineseTokenizerFactory"/> </analyzer> </fieldType>
以上配置就基本完成 现在来启动试试
C:\Users\Administrator>e:
E:\> cd Solr\solr-7.2.1\bin
E:\Solr\solr-7.2.1\bin>solr start -e cloud
Welcome to the SolrCloud example!
This interactive session will help you launch a SolrCloud cluster on your local
workstation.
To begin, how many Solr nodes would you like to run in your local cluster? (spec
ify 1-4 nodes) [2]:
按回车
Ok, let's start up 2 Solr nodes for your example SolrCloud cluster.
Please enter the port for node1 [8983]:
按回车
Please enter the port for node2 [7574]:
回车
Creating Solr home directory E:\Solr\solr-7.2.1\example\cloud\node1\solr
Cloning E:\Solr\solr-7.2.1\example\cloud\node1 into
E:\Solr\solr-7.2.1\example\cloud\node2
Starting up Solr on port 8983 using command:
"E:\Solr\solr-7.2.1\bin\solr.cmd" start -cloud -p 8983 -s "E:\Solr\solr-7.2.1\ex
ample\cloud\node1\solr"
Waiting up to 30 to see Solr running on port 8983
Started Solr server on port 8983. Happy searching!
Starting up Solr on port 7574 using command:
"E:\Solr\solr-7.2.1\bin\solr.cmd" start -cloud -p 7574 -s "E:\Solr\solr-7.2.1\ex
ample\cloud\node2\solr" -z localhost:9983
Waiting up to 30 to see Solr running on port 7574
Started Solr server on port 7574. Happy searching!
INFO - 2018-01-26 15:56:59.085; org.apache.solr.client.solrj.impl.ZkClientClust
erStateProvider; Cluster at localhost:9983 ready
Now let's create a new collection for indexing documents in your 2-node cluster.
Please provide a name for your new collection: [gettingstarted]
healthy 输入对应的节点名称 继续回车
How many shards would you like to split healthy into? [2]
回车
How many replicas per shard would you like to create? [2]
回车
Please choose a configuration for the healthy collection, available options are:
_default or sample_techproducts_configs [_default]
Created collection 'healthy' with 2 shard(s), 2 replica(s) with config-set 'heal
thy'
Enabling auto soft-commits with maxTime 3 secs using the Config API
POSTing request to Config API: http://localhost:8983/solr/healthy/config
{"set-property":{"updateHandler.autoSoftCommit.maxTime":"3000"}}
Successfully set-property updateHandler.autoSoftCommit.maxTime to 3000
SolrCloud example running, please visit: http://localhost:8983/solr
E:\Solr\solr-7.2.1\bin>
下面开始访问
好 同步完成.....