SOLR对多个(关联)表创建索引
2015-10-24 13:48
260 查看
又两天没写博客,关于SOLR的东西,写了一周了还没写完我也是醉了,毕竟会的东西真不多,周四晚上加班没写,周五晚上公司同事聚会也没写,今天在家,还是把最后的一点写完吧,我会的剩下的也就是一个对多个表创建索引了,表可以是关联的,也可以是不关联的,下面开始。
View Code
官方的解释是这样的:
In the above example, there are mappings of fields to Solr fields. It is possible to totally avoid the field entries in entities if the names of the fields are same (case does not matter) as those in Solr schema. You may need to add a field entry if any of the built-in Tranformers are used (see Transformer section)
接下来还是修改schema.xml文档,把需要创建索引的字段放到该文件中即可。
多表创建索引的方式我就介绍完了,虽然写的很粗糙,但是应该还有点用吧,更多的内容大家可以自己去查看官方文档的http://wiki.apache.org/solr/DataImportHandler这个地方,至于有人说都是英文看不懂,关于这个问题我想说的是其实我英文也是半吊子,但是借助一些翻译工具还是能看一点的,看的多了就看的懂了,不要怕看英文,坚持看下去总能看的懂的,就算你看不全懂,至少能明白大概说的什么意思就行啊,带蒙带猜的,这都不是事。
另外关于solr的其他东西我就暂时不不写了,一方面是因为我研究这个时间也不长,有些东西我也不是太懂,目前只能算是刚刚入门吧,另一方面,本来要用solr的项目又说不用了,新开的项目也是比较紧急,所以关于solr的东西也只好暂时先放下了,以后再用到的时候再捡起来继续吧。恩,暂时就这样了。
一、无关联多表创建索引
1.1数据库准备
首先在数据库创建一张表,本来有一个tuser表了,我又创建了一个role表,就两三个字段,没什么特殊的,然后在里面随便添加几条数据即可,看一下数据库:<dataConfig> <dataSource driver="org.hsqldb.jdbcDriver" url="jdbc:hsqldb:/temp/example/ex" user="sa" /> <document> <entity name="item" query="select * from item"> <entity name="feature" query="select description as features from feature where item_id='${item.ID}'"/> <entity name="item_category" query="select CATEGORY_ID from item_category where item_id='${item.ID}'"> <entity name="category" query="select description as cat from category where id = '${item_category.CATEGORY_ID}'"/> </entity> </entity> </document> </dataConfig>
View Code
官方的解释是这样的:
In the above example, there are mappings of fields to Solr fields. It is possible to totally avoid the field entries in entities if the names of the fields are same (case does not matter) as those in Solr schema. You may need to add a field entry if any of the built-in Tranformers are used (see Transformer section)
接下来还是修改schema.xml文档,把需要创建索引的字段放到该文件中即可。
多表创建索引的方式我就介绍完了,虽然写的很粗糙,但是应该还有点用吧,更多的内容大家可以自己去查看官方文档的http://wiki.apache.org/solr/DataImportHandler这个地方,至于有人说都是英文看不懂,关于这个问题我想说的是其实我英文也是半吊子,但是借助一些翻译工具还是能看一点的,看的多了就看的懂了,不要怕看英文,坚持看下去总能看的懂的,就算你看不全懂,至少能明白大概说的什么意思就行啊,带蒙带猜的,这都不是事。
另外关于solr的其他东西我就暂时不不写了,一方面是因为我研究这个时间也不长,有些东西我也不是太懂,目前只能算是刚刚入门吧,另一方面,本来要用solr的项目又说不用了,新开的项目也是比较紧急,所以关于solr的东西也只好暂时先放下了,以后再用到的时候再捡起来继续吧。恩,暂时就这样了。
相关文章推荐
- Contains Duplicate II - LeetCode
- 使用OC swift 截取路径中的最后的文件名
- Gson简要使用笔记
- Java中的泛型方法
- Java程序员们最常犯的10个错误
- ubuntu搭建git server
- C# 编写简单的控制台应用程序 显示如下数字金字塔
- 信息安全系统设计基础第7周学习总结
- 凸包 graham旋转扫描
- iPhone屏幕投射到Mac的解决方案
- leetcode 104 Maximum Depth of Binary Tree
- iOS7.0隐藏状态栏(statusBarHidden)
- java编程的78条黄金法则
- .gradle 文件简单介绍
- DP-HDU-1260-Tickets
- N皇后问题算法
- HDU——2006 求奇数的乘积
- N皇后问题算法
- c++web方案
- Android docs4.3API