内容简介:去除lucene繁琐的操作,让你专注于实现业务! 文档 简介:https://gitee.com/Myzhang/luceneplus/blob/master/README.md javadoc:https://apidoc.gitee.com/Myzhang/luceneplus Demo:https://gitee.com/Myzhang...
去除lucene繁琐的操作,让你专注于实现业务!
文档
简介:https://gitee.com/Myzhang/luceneplus/blob/master/README.md
javadoc:https://apidoc.gitee.com/Myzhang/luceneplus
Demo:https://gitee.com/Myzhang/luceneplus/tree/master/src/test/java/com/ld/lucenex/demo
特点
- 原生lucene用法
- 天然支持多数据源
- 自带数据源创建和垃圾回收
- 默认实现近实时索引
- MyDocument 加持 支持 map、json、obj 自动转换
- 一键高亮支持
- 统一的service接口思想
- 注解式声明字段
入门
创建lucene数据源
new LuceneX(new LuceneXConfig() { @Override public void configLuceneX(BaseConfig me) { me.add("d:/","test",Empty.class); } });
定义实体类
import com.ld.lucenex.field.FieldKey; import com.ld.lucenex.field.LDType; public class Empty{ @FieldKey(type = LDType.IntPoint) private int id; @FieldKey(type = LDType.StringField) private String name; @FieldKey(type = LDType.TextField,highlight = true) private String text; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getText() { return text; } public void setText(String text) { this.text = text; } }
添加索引
List<Empty> empties = new ArrayList<>(10); for (int i=0;i<10;i++){ Empty empty = new Empty(); empty.setId(i); empty.setName("新闻"); empty.setText("8月29日,2019世界人工智能大会在上海开幕,本届大会以“智联世界,无限可能”为主题,展示包括中国在内各国最新的AI产品和技术。在本届大会上,除了各国展出的最新AI技术和产品外,由华为、寒武纪、依图等国内企业自主研发的人工智能芯片组成的AI芯片墙更是受到参观者的关注。图为微软带来了智能菜品识别系统,把食物放在收银检测区,便能自觉识别价格。更厉害的是,系统还能给出营养分析报告,例如热量、脂肪、碳水物、蛋白质等含量。"); empties.add(empty); } ServiceImpl<Empty> basisService = ServiceFactory.getService(ServiceImpl.class); basisService.addObjects(empties);
查询索引
ServiceImpl<Empty> basisService = ServiceFactory.getService(ServiceImpl.class); Empty searchOne = basisService.searchOne(new TermQuery(new Term("name","百度一下")));
高亮显示条件
- 字段表明 highlight = true,并且 type = LDType.TextField
@FieldKey(type = LDType.TextField,highlight = true) private String text;
- 必须调用searchList 并且返回类型是
实时索引条件
- 必须调用ServiceImpl内置的添加/更新删除方法
如何自定义 Service 查询接口
import com.ld.lucenex.service.ServiceImpl; public class DemoService<T> extends ServiceImpl<T> { public DemoService(String sourceKey) { super(sourceKey); } }
如何与其他web/非web框架集成
- 只要在项目启动的时候 创建lucene数据源即可
更新日志
v2.1
- 去除一个递归调用接口bug
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- MyExcel 3.7.3 版本发布,漏洞修复&简化
- KDE Plasma 5.12.4 发布,简化任务视图
- GitLab 9.2 发布,简化多人协作&增强本地化
- Neditor 2.1.1 发布:简化上传配置,更改相关注释
- 龙芯派二代发布,简化国产软硬件开发难度
- Fundebug发布Vue插件,简化BUG监控接入代码
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Domain-Driven Design Distilled
Vaughn Vernon / Addison-Wesley Professional / 2016-6-2 / USD 36.99
Domain-Driven Design (DDD) software modeling delivers powerful results in practice, not just in theory, which is why developers worldwide are rapidly moving to adopt it. Now, for the first time, there......一起来看看 《Domain-Driven Design Distilled》 这本书的介绍吧!