去除lucene繁瑣的操作,讓你專註於實現業務!
原生lucene用法
天然支持多數據源
自帶數據源創建和垃圾回收
默認實現近實時索引
MyDocument 加持 支持 map、json、obj 自動轉換
一鍵高亮支持
統一的service介面思想
註解式聲明欄位
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數據源即可
去除一個遞歸調用介面bug
[admin
]