侧边栏壁纸
  • 累计撰写 793 篇文章
  • 累计创建 1 个标签
  • 累计收到 1 条评论
标签搜索

目 录CONTENT

文章目录

数据导入

Dettan
2021-04-10 / 0 评论 / 0 点赞 / 174 阅读 / 542 字
温馨提示:
本文最后更新于 2022-07-23,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
core文件夹里的solrconfig.xml
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
  <lst name="defaults">
    <str name="config">DIHconfig.xml</str>
  </lst>
</requestHandler>

同文件夹下创建一个DIHconfig.xml
官方示例
<dataConfig>
  <dataSource driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:./example-DIH/hsqldb/ex" 
    user="sa" password="secret"/> 
  <document> 
    <entity name="item" query="select * from item"
            deltaQuery="select id from item where last_modified > '${dataimporter.last_index_time}'"> 
      <field column="NAME" name="name" />

      <entity name="feature"
              query="select DESCRIPTION from FEATURE where ITEM_ID='${item.ID}'"
              deltaQuery="select ITEM_ID from FEATURE where last_modified > '${dataimporter.last_index_time}'"
              parentDeltaQuery="select ID from item where ID=${feature.ITEM_ID}"> 
        <field name="features" column="DESCRIPTION" />
      </entity>

      <entity name="item_category"
              query="select CATEGORY_ID from item_category where ITEM_ID='${item.ID}'"
              deltaQuery="select ITEM_ID, CATEGORY_ID from item_category where last_modified > '${dataimporter.last_index_time}'"
              parentDeltaQuery="select ID from item where ID=${item_category.ITEM_ID}">
        <entity name="category"
                query="select DESCRIPTION from category where ID = '${item_category.CATEGORY_ID}'"
                deltaQuery="select ID from category where last_modified > '${dataimporter.last_index_time}'"
                parentDeltaQuery="select ITEM_ID, CATEGORY_ID from item_category where CATEGORY_ID=${category.ID}">
          <field column="description" name="cat" />
        </entity>
      </entity>
    </entity>
  </document>
</dataConfig>
自用
<dataConfig>
  <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/shop?characterEncoding=utf-8" 
    user="root" password="root"/> 
  <document> 
	<entity name="item" query="select * from tb_item">
		<field  name="id" column="id" />
		<field name="item_title" column="title"/>
		<field name="item_sell_point" column="sell_point"/>
		<field name="item_price" column="price"/>
		<field name="item_image" column="image"/>
		<entity name = "category" query="select name from tb_item_cat where id = '${item.cid}'" >
			<field name="item_category_name" column="name" />    
		</entity>
	</entity>
  </document>
</dataConfig>

从D:\JAVA\code\solr-8.3.0\dist 里拷贝jar包到 D:\JAVA\code\solr-8.3.0\server\solr\new_core\lib
mysql-connector-java-5.1.32.jar solr-dataimporthandler-8.3.0.jar solr-dataimporthandler-extras-8.3.0.jar


重启

0

评论区