solr4.5笔记(三)—— solr导入mysql数据
2013-10-24 13:53
381 查看
这里修改core1来实现mysql的数据导入(所需jar第一篇文章已经加过了),这里只是示例具体请根据自己的需要稍微改一下
PS:如果修改core1库的名字 换为 test,需要把solrconfig.xml里面的${solr.core1.data.dir:} 全部改为${solr.test.data.dir:}
1、修改solrconfig.xml
添加如下:
在同一目录下新建一个data-config.xml
修改schema.xml
重启solr使配置生效
打开
导入数据可以看到 跟data-config.xml的配置是对应的
导入完成后查看一下数据 和是否分词
查看分词结果 在schema.xml配置文件中 只指定了companyName、brandName、product进行分词(type指定)所以只看这几个词的分词结果
到此导入mysql数据已经结束
http://www.iteye.com/topic/759148
下一篇记录定时跟新索引文件
PS:如果修改core1库的名字 换为 test,需要把solrconfig.xml里面的${solr.core1.data.dir:} 全部改为${solr.test.data.dir:}
1、修改solrconfig.xml
添加如下:
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>
在同一目录下新建一个data-config.xml
<dataConfig> <dataSource name="companyDump" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8" user="root" password="root"/> <document> <entity name="company" query="select id,slogan,companyName,categoryId,categoryName,xcategoryName,xcategoryId,regtime,invest,shopNum,url,brandName,product,managementMode,level,logo,createDate from company_basicinfo where isDelete=0 and isActive=1" deltaImportQuery="select id,slogan,companyName,categoryId,categoryName,xcategoryName,xcategoryId,regtime,invest,shopNum,url,brandName,product,managementMode,level,logo,createDate from company_basicinfo where isDelete=0 and isActive=1 and id='${dataimporter.delta.id}'" deltaQuery="select id from company_basicinfo where isDelete=0 and isActive=1 and updateDate > '${dataimporter.last_index_time}'"> <field column="slogan" name="slogan"/> <field column="companyName" name="companyName"/> <field column="categoryId" name="categoryId"/> <field column="categoryName" name="categoryName"/> <field column="xcategoryId" name="xcategoryId"/> <field column="xcategoryName" name="xcategoryName"/> <field column="regtime" name="regtime"/> <field column="invest" name="invest"/> <field column="shopNum" name="shopNum"/> <field column="url" name="url"/> <field column="brandName" name="brandName"/> <field column="product" name="product"/> <field column="managementMode" name="managementMode"/> <field column="level" name="level"/> <field column="logo" name="logo"/> <field column="createDate" name="createDate"/> </entity> </document> </dataConfig>
修改schema.xml
<?xml version="1.0" ?> <schema name="companySchema" version="1.1"> <types> <fieldType name="string" class="solr.StrField" sortMissingLast="true"/> <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/> <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/> <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/> <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/> <fieldType name="tdate" class="solr.TrieDateField" precisionStep="8" positionIncrementGap="0"/> <fieldType name="textMaxWord" class="solr.TextField" > <analyzer> <tokenizer class="com.chenlb.mmseg4j.solr.MMSegTokenizerFactory" mode="max-word"/> </analyzer> </fieldType> </types> <fields> <field name="id" type="tint" indexed="true" stored="true" required="true"/> <field name="companyName" type="textMaxWord" indexed="true" stored="true"/> <field name="slogan" type="string" indexed="true" stored="false"/> <field name="categoryId" type="tint" indexed="true" stored="true"/> <field name="categoryName" type="string" indexed="false" stored="true"/> <field name="xcategoryId" type="tint" indexed="true" stored="true"/> <field name="xcategoryName" type="string" indexed="false" stored="true"/> <field name="regtime" type="string" indexed="false" stored="true"/> <field name="invest" type="tint" indexed="true" stored="true"/> <field name="shopNum" type="string" indexed="true" stored="true"/> <field name="url" type="string" indexed="false" stored="true"/> <field name="brandName" type="textMaxWord" indexed="true" stored="false"/> <field name="product" type="textMaxWord" indexed="true" stored="false"/> <field name="managementMode" type="string" indexed="false" stored="true"/> <field name="level" type="tint" indexed="true" stored="true"/> <field name="logo" type="string" indexed="false" stored="true"/> <field name="createDate" type="tdate" indexed="true" stored='true'/> <field name="_version_" type="tlong" indexed="true" stored="true"/> </fields> <uniqueKey>id</uniqueKey> <defaultSearchField>companyName</defaultSearchField> <solrQueryParser defaultOperator="OR"/> </schema>
重启solr使配置生效
打开
导入数据可以看到 跟data-config.xml的配置是对应的
导入完成后查看一下数据 和是否分词
查看分词结果 在schema.xml配置文件中 只指定了companyName、brandName、product进行分词(type指定)所以只看这几个词的分词结果
到此导入mysql数据已经结束
http://www.iteye.com/topic/759148
下一篇记录定时跟新索引文件
相关文章推荐
- solr4.5 mysql 配置数据导入
- solr学习笔记-导入mysql数据
- solr 6 导入mysql 数据
- Python - mysql中导入CSV数据 【学习笔记】
- solr全量导入/增量导入mysql的数据
- java搜索引擎Apache的solr初探-安装使用导入mysql数据
- solr简单安装mysql导入同步数据
- Solr之搭建Solr6.0服务并从Mysql上导入数据
- Solr之搭建Solr6.0服务并从Mysql上导入数据
- Solr之搭建Solr6.0服务并从Mysql上导入数据
- Solr导入mysql数据建全量索引
- 从mysql数据库中导入数据到solr4.5
- solr4.0安装和简单导入mysql数据
- Kettle学习笔记一 :MySQL到Postgres导入数据且发送日志邮件
- 从mysql数据库中导入数据到solr4.5
- Solr之搭建Solr5.2.1服务并从Mysql上导入数据
- solr实践(2)-- Solr6.2.0从Mysql上导入数据
- Solr 学习笔记(三) 数据导入
- [MySql学习笔记] 二 数据导入导出
- Solr配置从Mysql导入数据到索引库