基于JDK 1.8 & lucene 7.x 的搜索框架、在不影响原本性能的同时、提升80%的开发效率、降低70%的开发难度!!!
去除第三方分词依赖&无用的Jar 使用cglib 动态代理创建 Service 新增拦截器 添加更新 默认异步
public class DemoConfig extends LuceneXConfig{ @Override public void configConstant(Constants me) { } @Override public void configLuceneX(BaseConfig me) { // 存储目录 、名称、高亮、分词器、存储类 me.add("d:/", "test", false, new PerFieldAnalyzerWrapper(new StandardAnalyzer()), Empty.class); } }
//默认使用第一个存储库(如果您只有一个库或使用第一个库的话) BasisService basisService = LdService.newInstance(BasisService.class); //自定义使用库 BasisService basisService = LdService.newInstance(BasisService.class,"test");
public List TermQuery(String field,String value,int num) public long IntDelete(String field,int value) public void addIndex(List> list) public List searchList(Query query, int n) public Page searchList(Query query,Page page) public List searchTotal() public long addDocuments(Iterable extends Iterable extends IndexableField>> docs) public long addDocument(Iterable extends IndexableField> doc) public int count(Query query) public TopDocs search(Query query, int n) public TopFieldDocs search(Query query, int n, Sort sort) public long deleteAll() public long deleteDocuments public long deleteDocuments(Term... terms) public void deleteUnusedFiles() public long updateIndex(List list,Term term) public List toDocument(List> list) public void goBack()
//手动启动 LuceneX.start(DemoConfig.class);
private String indexPath;//存储地址 private boolean highlight;//是否高亮 private IndexWriter writer;//写入对象 private IndexSearcher searcher;//查询对象 private PerFieldAnalyzerWrapper analyzer;//分词器 private Class> defaultClass;//存储对象Class private Highlighter highlighter;//高亮标签
default public int count(Query query) throws IOException { return config.getSearcher().count(query); }