solr链接数据库
来源:互联网 发布:纸质读书笔记 知乎 编辑:程序博客网 时间:2024/05/29 10:56
1. 向D:\Solr\home\conf\solrconfig.xml添加以下内容
<requestHandlername="/dataimport"class="org.apache.solr.handler.dataimport.DataImportHandler">
<lstname="defaults">
<strname="config">data-config.xml</str>
</lst>
</requestHandler>
2.在微软的网站上下载JDBC for sqlserver,http://www.microsoft.com/zh-CN/download/details.aspx?id=11774
将其中的sqljdbc.jar或sqljdbc4.jar包放到web-inf\lib目录中
3.在相同目录下建立data-config.xml添加以下内容
<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://localhost:1433;DatabaseName=testDB" user="sa" password="sa"/>
<document name="Goods">
<entity name="Goods" query="select * from View_GoodsInfo" transformer="ClobTransformer">
<field column="Goods_ID" name="Goods_ID" />
<field column="Goods_Name" name="Goods_Name" />
<field column="Goods_TypeID" name="Goods_TypeID" />
<field column="Goods_TypeName" name="Goods_TypeName" />
<field column="Goods_Introduction" name="Goods_Introduction" clob="true" />
</entity>
</document>
</dataConfig>
解释一下clob,Character Large Object,字符大对象,比如sql server中的text
注:如果连接默认实例,那么一定要写上端口号。如果是命名实例,一定不要写上端口号,jdbc:sqlserver://localhost;instanceName=testName; DatabaseName=testDB", "sa","sa"或者
jdbc:sqlserver://localhost//testName; DatabaseName=testDB", "sa","sa"
4.在schema.xml的fields节点加入以下内容
<field name="Goods_ID" type="text" indexed="true" stored="true"/>
<field name="Goods_Name" type="text" indexed="true" stored="true"/>
<field name="Goods_TypeID" type="text" indexed="true" stored="true"/>
<field name="Goods_TypeName" type="text" indexed="true" stored="true"/>
<field name="Goods_Introduction" type="text" indexed="true" stored="true"/>
Fields 字段 : 结点内定义具体的字段(类似数据库中的字段) , 就是 field ,
name: mandatory - the name for the field
type: mandatory - the name of a previously defined type from the
<types> section
indexed: true if this field should be indexed (searchable or sortable)
stored: true if this field should be retrievable
multiValued: true if this field may contain multiple values per document
omitNorms: (expert) set to true to omit the norms associated with
this field (this disables length normalization and index-time
boosting for the field, and saves some memory). Only full-text
fields or fields that need an index-time boost need norms.
Norms are omitted for primitive (non-analyzed) types by default.
termVectors: [false] set to true to store the term vector for a
given field.
When using MoreLikeThis, fields used for similarity should be
stored for best performance.
termPositions: Store position information with the term vector.
This will increase storage costs.
termOffsets: Store offset information with the term vector. This
will increase storage costs.
default: a value that should be used if no value is specified
when adding a document.
copeField(赋值字段): 建立一个拷贝字段 , 将所有的全文字段复制到一个字段中 , 以便进行统一的检索 。
copyField commands copy one field to another at the time a document
is added to the index. It's used either to index the same field differently,
or to add multiple fields to the same field for easier/faster searching.
dynamicField:
Dynamic field definitions. If a field name is not found, dynamicFields
will be used if the name matches any of the patterns.
RESTRICTION: the glob-like pattern in the name attribute must have
a "*" only at the start or the end.
EXAMPLE: name="*_i" will match any field ending in _i (like myid_i, z_i)
Longer patterns will be matched first. if equal size patterns
both match, the first appearing in the schema will be used.
5. 将解压的solr文件夹中dist 目录下的 apache-solr-dataimporthandler-3.6.1.jar 和 apache-solr-dataimporthandler-extras-3.6.1.jar复制到 D:\apache-tomcat-6.0.29\webapps\solr\WEB-INF\lib
6.访问http://localhost:8080/solr/dataimport?command=full-import就可以导入数据
- solr链接数据库
- win 下 solr 链接数据库并把数据导入到solr中
- solr 数据库
- solr学习相关链接
- solr 索引mysql DIH 链接
- solr最新应用链接分享
- solr导入数据库数据
- Solr配置SqlServer数据库
- Solr连接数据库配置
- Solr连接数据库
- solr导入数据库数据
- solr 导入数据库
- solr配数据库介绍
- solr同步mysql数据库
- [solr] - 数据库导入
- [solr] - 数据库导入
- [solr] - 数据库导入
- solr-数据库导入
- 字典树——Hdu 1247 Hat’s Words
- MyEclipse8.6 Io 异常: The Network Adapter could not establish the connection
- 域用户自助修改AD属性Web应用 - ADCustomWeb
- android的编译和运行过程
- 网站排障分析常用的命令
- solr链接数据库
- 网站小说采集
- 枚举
- OpenGL函数思考-glHint
- Win 7 下确定是否有管理员权限!
- 数据恢复的基础知识
- 低级格式化
- 在ubuntu 编译感想
- OpenStack资源整理(转自陈沙克)