基於JDK 1.8 & lucene 8.x 的搜索框架、在不影響原本性能的同時、提升80%的開發效率、降低70%的開發難度!!!
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; } }
Listempties = 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); } ServiceImplbasisService = ServiceFactory.getService(ServiceImpl.class); basisService.addObjects(empties);
ServiceImplbasisService = 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內置的添加/更新刪除方法
import com.ld.lucenex.service.ServiceImpl; public class DemoServiceextends ServiceImpl{ public DemoService(String sourceKey) { super(sourceKey); } }
只要在項目啟動的時候 創建lucene數據源即可
大量改動與之前版本不兼容
新增關閉保護,jvm停止前提交所有隊列里的數據,保證數據的完整性
新增 IndexSource 類代表每一個數據源
優化 LuceneX 統一資源管理
新增 MyDocument 代替 Object 轉 Document 方法
新增 ServiceImpl
新增 ServiceFactory
升級 lucene 為 8.2.0
新增 searchOneDoc 方法
新增 SimpleExample 用例
增加單個對象添加索引
同步實時索引
增加jfinal、springboot、servlet等集成插件
精簡代碼
增加兩個實用方法
刪除2個依賴
適配 javabean and map and fastjson 直接添加
自動提交&關閉數據、避免丟失數據或手動提交
補充大量文檔註釋
精簡&優化代碼
修復一個錯誤的Demo
去除第三方分詞依賴&無用的Jar
使用cglib 動態代理創建 Service
新增攔截器
添加更新 默認非同步
輕 ~ 不足千行
簡 ~ 零配置項
全 ~ 內置豐富
易 ~ 入門簡單
快 ~ 接近原生
穩 ~ 堅如磐石
展 ~ 插件擴展
原聲Lucene 用法
註解式聲明欄位
多庫自動切換
自帶管理資源創建於釋放
自帶高性能近實時索引
可持續擴展的Service 介面設計
內置豐富常用介面
可直接添加Java對象與Map集合 無需手動創建 Document
支持操作回退
可自定義分詞器
異常退出數據保護
QQ群號:475349334
下載后使用Maven打包成jar
[admin
]