zoukankan      html  css  js  c++  java
  • windows 搭建Solr连接数据库

     话不多说直接上图

    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:UsersAdministrator>e:
    
    E:> cd Solrsolr-7.2.1in
    
    E:Solrsolr-7.2.1in>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:Solrsolr-7.2.1examplecloud
    ode1solr
    Cloning E:Solrsolr-7.2.1examplecloud
    ode1 into
       E:Solrsolr-7.2.1examplecloud
    ode2
    
    Starting up Solr on port 8983 using command:
    "E:Solrsolr-7.2.1insolr.cmd" start -cloud -p 8983 -s "E:Solrsolr-7.2.1ex
    amplecloud
    ode1solr"
    
    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:Solrsolr-7.2.1insolr.cmd" start -cloud -p 7574 -s "E:Solrsolr-7.2.1ex
    amplecloud
    ode2solr" -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:Solrsolr-7.2.1in>

    下面开始访问

    好 同步完成.....

  • 相关阅读:
    绳关节(b2RopeJoint)
    公式推导 圆面积公式 圆周长公式
    ALTER TABLE causes auto_increment resulting key 'PRIMARY'
    MySQL通过Binlog恢复删除的表
    Barracuda VS antelope
    mysqldump 参数说明
    MySQL复制
    MySQL Server-id的作用
    MySQL 简洁连接数据库方式
    Kill 所有MySQL进程
  • 原文地址:https://www.cnblogs.com/fanghuagege/p/8360551.html
Copyright © 2011-2022 走看看