分析wda-lucene
来源:互联网 发布:传奇3装备数据库 编辑:程序博客网 时间:2024/05/17 22:22
项目
wda:https://www.oschina.net/p/wda
WDA 是一个 BS 架构的文档转换中间件,配合 openoffice 实现文档的在线预览。
概述
checkout此项目,本地git库会有3个文件,今天我们来简单说下wda-lucene。
wda-api
wda-lucene
wda-web
核心代码
创建索引
public class DoIndexTest { /** * 1.需要设置一个indexDir(索引路径),lucene会根据此索引路径建立索引。 * 2.创建索引生成器 * 3.设置docId,docName * 4.建立索引 * 5.关闭索引生成器 */ private static File indexDir = new File("e:\\temp\\index"); public static void main(String[] args) throws Exception { DocIndexInter dii = DocIndexImpl.getInstance(indexDir); DocMap mpa = new DocMap(UUID.randomUUID().toString()); String text = "分词器的建议使用,IKAnalyzer,在开源中文分词器里算是很好的, 而且一直在稳定的更新版本。"; //存储配置:Store.YES 索引配置:Index.ANALYZED mpa.put("TEXT", text,Store.YES, Index.ANALYZED); dii.indexDoc(mpa); dii.close(); }}
查询文件
public class DoQueryTest { /** * 指定查询路径、语句,即可完成查询,是不是很简单,跟sql的用法一样! * 例如:我们查询刚才插入到硬盘里的索引文件,查询关键词为【分词器】 */ private static File indexDir = new File("e:\\temp\\index"); public static void main(String[] args) throws Exception { DocQueryInter query = DocQueryImpl.getInstance(indexDir); IRResult result = query.query("WHERE(TEXT=分词器) ORDER_BY(TEXT:STRING ASC)", 1, 10); for (Map<String, Object> node : result.getResultList()) { System.out.println(node.get("TEXT")); System.out.println(node.get("ID")); } }}
控制台输出:<font color=red>分词器</font>的建议使用,IKAnalyzer,在开源中文<font color=red>分词器</font>里算是很好的,而且一直在稳定的更新版本。c8295d38-1b03-44a8-a69d-3ba7da55f2bb
删除索引
public class DocDelete { /** * 指定索引路径和docId,即可删除索引 */ private static File indexDir = new File("e:\\temp\\index"); public static void main(String[] args) throws Exception { DocIndexInter dii = DocIndexImpl.getInstance(indexDir); String docId = "bb73f6bc-eab9-43ff-892b-7e0f32b0375c"; dii.deleteFhysicsIndex(docId); dii.close(); }}
0 0
- 分析wda-lucene
- WDA Architecture
- WDA WDR_TEST_INPUT
- Lucene-Analysis包分析
- Lucene的特性分析
- Lucene的特性分析
- Lucene架构简单分析
- Lucene的特性分析
- Lucene系统结构分析
- lucene系统结构分析
- lucene分析器分析
- Lucene源码分析-- Analyzer
- lucene 源码分析
- lucene文件格式分析
- Lucene 结构分析
- lucene-Nutch分析
- Lucene索引文件格式分析
- lucene索引结构分析
- 微服务架构的分布式事务解决方案
- Sonatype Nexus 搭建Maven仓库
- android intent传递对象和集合
- Spring Session + Redis实现分布式Session共享
- Leetcode-Nim Game
- 分析wda-lucene
- .htaccess文件验证
- Fish to be a skilled programmer—second day
- 一个什么都不懂的程序员的服务器折腾日志
- iOS开发tableview为什么没有调用heightForRowAtIndexPath方法
- 重新建立wordpress个人博客之旅
- 网狐6603开发闲来麻将房卡源码(手机端+服务器+数据库)全套源码下载
- Velocity 使用笔记
- cf615Multipliers+N的约数的乘积