基于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; } }
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","百度一下")));
@FieldKey(type = LDType.TextField,highlight = true) private String text;
import com.ld.lucenex.service.ServiceImpl; public class DemoService<T> extends ServiceImpl<T> { public DemoService(String sourceKey) { super(sourceKey); } }
下载后使用Maven打包成jar