Lucene removing tedious operations, so you focus on achieving business!
File
Description: 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
Feature
- Primeval lucene usage
- Natural supports multiple data sources
- It comes with a data source creation and garbage collection
- Default achieve near real-time indexing
- MyDocument blessing support map, json, obj automatic conversion
- A key highlight support
- The idea of a unified service interfaces
- Notes declared field
getting Started
Creating a data source lucene
new LuceneX(new LuceneXConfig() { @Override public void configLuceneX(BaseConfig me) { me.add("d:/","test",Empty.class); } });
Defined entity classes
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; } }
Add index
List <Empty> = new new empties the ArrayList <> (10); for (int I = 0; I <10; I ++) { Empty Empty new new empty = (); empty.setId (I); empty.setName ( "News" ); empty.setText ( "August 29, 2019 opening of the World Conference on artificial Intelligence in Shanghai, this General Assembly to" Zhaopin world, endless possibilities "as the theme, showing the latest national AI products and technologies, including China in this. session of the General Assembly, in addition to the latest AI technology and products on display various countries, AI chip wall Huawei, Cambrian, in accordance with plans and other domestic independent research and development of artificial intelligence chips even more attention by the visitors. the picture shows Microsoft brings intelligent recognition system dishes, put food on the cash register detection zone will be able to identify the price conscious, more powerful, the system also gives nutritional analysis reports, such as the content of calories, fat, carbohydrates, protein and so on. ") ; empties.add (empty); } the ServiceImpl <empty> basisService = ServiceFactory.getService (ServiceImpl.class); basisService.addObjects (empties);
Query Index
ServiceImpl<Empty> basisService = ServiceFactory.getService(ServiceImpl.class); Empty searchOne = basisService.searchOne(new TermQuery(new Term("name","百度一下")));
Highlight condition
- Field indicates highlight = true, and type = LDType.TextField
@FieldKey(type = LDType.TextField,highlight = true) private String text;
- You must call and return type is searchList
Real-time conditions index
- You must call ServiceImpl built-in Add / Update Delete method
How to customize Service query interface
import com.ld.lucenex.service.ServiceImpl; public class DemoService<T> extends ServiceImpl<T> { public DemoService(String sourceKey) { super(sourceKey); } }
How to integrate with other web / non web framework
- As long as the data source to create lucene when the project starts
Update Log
v2.1
- Removing a recursive call interface bug