lucene全文检索与数据库检索的区别
2016-03-30 20:41
337 查看
1.性能
数据库:like检索(会把表中数据进行一行一行的扫描,)性能慢
Lucene检索:先把数据那过来建立检索,然后在根据建立的索引进行查找,这样的话我们需要多维护一份索引表。多一个创建索引的过程,但是我们是一次创建多次使用。
2:相关度排序
数据库检索:通过 order by 关键字来操作。
Lucene检索:对查询出来的每个document都有一个算法,(得分)得分是根据算法算出来的。得分越高,排序的顺序越靠前。
排序可以人工干预(通过设置权重值)
代码:
public static Document articleToDocument(Article article){
Document document=new Document();
IntField idfield=new IntField("id",article.getId(),Store.YES);
StringField authorfield=new StringField("author", article.getAuthor(), Store.YES);
StringField urlfield=new StringField("link", article.getLink(), Store.YES);
TextField title=new TextField("title", article.getTitle(),Store.YES);
//设置权重值,默认为1f..
title.setBoost(4f);
TextField contentfield=new TextField("content", article.getContent(),Store.YES);
document.add(idfield);
document.add(authorfield);
document.add(urlfield);
document.add(title);
document.add(contentfield);
return document;
}
3:匹配的准确度
数据库检索: 通过like 关键字进行检索 其中相关文字得用 % 来表示 如:like %ant%
Lucene检索:先把数据拿过来分词建立索引,根据建好的索引进行查找。
数据库:like检索(会把表中数据进行一行一行的扫描,)性能慢
Lucene检索:先把数据那过来建立检索,然后在根据建立的索引进行查找,这样的话我们需要多维护一份索引表。多一个创建索引的过程,但是我们是一次创建多次使用。
2:相关度排序
数据库检索:通过 order by 关键字来操作。
Lucene检索:对查询出来的每个document都有一个算法,(得分)得分是根据算法算出来的。得分越高,排序的顺序越靠前。
排序可以人工干预(通过设置权重值)
代码:
public static Document articleToDocument(Article article){
Document document=new Document();
IntField idfield=new IntField("id",article.getId(),Store.YES);
StringField authorfield=new StringField("author", article.getAuthor(), Store.YES);
StringField urlfield=new StringField("link", article.getLink(), Store.YES);
TextField title=new TextField("title", article.getTitle(),Store.YES);
//设置权重值,默认为1f..
title.setBoost(4f);
TextField contentfield=new TextField("content", article.getContent(),Store.YES);
document.add(idfield);
document.add(authorfield);
document.add(urlfield);
document.add(title);
document.add(contentfield);
return document;
}
3:匹配的准确度
数据库检索: 通过like 关键字进行检索 其中相关文字得用 % 来表示 如:like %ant%
Lucene检索:先把数据拿过来分词建立索引,根据建好的索引进行查找。
相关文章推荐
- Redis 配置文件总结
- Oracle学习(九)----表的增删改查,回收站
- 缓存技术PK:选择Memcached还是Redis(转)
- VS配置、编译sqlite失败的解决方法
- 关于 msql 使用过程中的总结
- mysql 时间戳格式化函数from_unixtime使用说明
- 【Redis】简介与安装
- (4.6.2)数据库性能优化
- ubuntu 15.04 通过3306端口远程连接mysql
- 数据分页的实现
- 转载文章----十步完全理解SQL
- 26、Java调用Oracle存储过程?
- 数据库关系代数练习题
- SQLPlus在连接时通常有四种方式
- SQL Server使用文件组备份降低备份文件占用的存储空间
- 虚拟机VMWare安装RHEL 7.0以及安装配置LAMP环境(Apache+PHP+MariaDB)
- Mybatis 控制台输出sql信息
- memcached学习笔记1(windows 7 64bit 环境下安装memcached)
- Mysql学习笔记之常用数据类型
- 数据库的四个范式之间的区别