dataimport

solr发布起来以后,

  1. copy一个collection1作为自己的例子,并命名job;

dataimport

2.修改job下的core.properties如下:

name=job

config=solrconfig.xml  

schema=schema.xml  

dataDir=data  

3.在job/conf/solrconfig.xml中配置

<script>alert(1)</script>

<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">      <lst name="defaults">          <str name="config">data-config.xml</str>      </lst> </requestHandler>

一个dataimport的handler,指定数据源:data-config.xml

4.在job/conf/data-config.xml中配置数据源

<dataConfig>  <dataSource type="JdbcDataSource"              driver="com.mysql.jdbc.Driver"              url="jdbc:mysql://115.231.888.xxx:3306/***?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull"              user="****"              password="****"              batchSize="-1" autoCommit="true"/>  <document>    <entity name="job" pk="job_id"          query="SELECT job_id, a.shop_id, b.shop_company, b.shop_name,b.shop_logo,b.people_scale_start, b.people_scale_end, f.industry_name, a.position_id, c.position_name, a.job_name, a.month_pay_start, a.month_pay_end, a.job_goodness, a.welfare_mark, a.job_about, a.gender, a.area_id, d.full_name AS area_name, a.job_require_start, a.job_require_end, a.degree_id, e.degree_name, a.job_desc, a.update_date FROM jobs.org_shop_job a, jobs.org_shop_base b, jobs.conf_position c, jobs.conf_area d, jobs.conf_degree e, jobs.conf_industry f WHERE a.is_enabled = 1 AND a.shop_id = b.shop_id AND a.position_id = c.position_id AND a.area_id = d.area_id AND a.degree_id = e.degree_id AND b.industry_id = f.industry_id">  <field column="job_id" name="job_id"/>  <field column="shop_name" name="shop_name" />  <field column="shop_logo" name="shop_logo" />  <field column="shop_company" name="shop_company" />  <field column="people_scale_start" name="people_scale_start" />  <field column="people_scale_end" name="people_scale_end" />  <field column="position_id" name="position_id"  />  <field column="position_name" name="position_name" />  <field column="job_name" name="job_name" />  <field column="job_goodness" name="job_goodness" />  <field column="job_about" name="job_about"/>  <field column="gender"  name="gender" />  <field column="welfare_mark" name="welfare_mark"  />  <field column="industry_name" name="industry_name" />  <field column="month_pay_start" name="month_pay_start"  />  <field column="month_pay_end" name="month_pay_end" />  <field column="area_id" name="area_id" />  <field column="area_name" name="area_name" />  <field column="degree_id" name="degree_id" />  <field column="degree_name" name="degree_name"/>  <field column="job_require_start" name="job_require_start"  />  <field column="job_require_end" name="job_require_end" />  <field column="update_date" name="update_date" />  <field column="job_desc" name="job_desc" />    </entity>  </document></dataConfig>

5.修改schema.xml,其实schema.xml我不是很懂,简略过;

6.执行dataimport--excute,就可以建立索引了;


再dataimport过程中遇到很多的问题,解决方案主要如下;

  1. http://leil.info/archives/solr-4-3%E7%9A%84%E4%B8%80%E4%BA%9B%E9%94%99%E8%AF%AF%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/

  2. http://blog.csdn.net/jaylong35/article/details/9031075


你可能感兴趣的:(dataimport)