一个简单的Lucene工具类,通过注释的方式来配置构建索引的字段。提供新建索引、查找、删除、更新方法,支持分页。
Lucene • pengshaojie 发表了文章 • 6 个评论 • 4230 次浏览 • 2018-02-12 10:23
### wsm-lucene
一个简单的Lucene工具类,通过注释的方式来配置构建索引的字段。提供新建索引、查找、删除、更新方法,支持分页。
### 所需jar包
1. lucene-core:2.4.0
2. lucene-analyzers:2.4.1
3. commons-logging:1.2
### 背景
以前在做某个feature的时候,鉴于存储在DB中的数据量过大,故使用Lucene来优化查找性能。
相信大家在某些场景下会把DB中的数据读出来,建索引来优化查找。那么这个工具类就比较适合这些场景了。
### 如何使用
**从附件中下载jar包直接导入到项目中,或者下载此Maven项目的源码,使用项目依赖的方式导入你的项目。**
1. 通过注释的方式配置需要构建索引的model类
```
**@IndexClass** :注释,说明此model类需要构建索引
**indexDirPath** :索引所存放的物理位置,如:"D:/Index"
**@IndexField** :注释,说明此字段需要构建索引
**fieldStore** :Lucene中的Field.Store同义,不懂请自行查询资料
**fieldIndex** :Lucene中的Field.Index同义,不懂请自行查询资料
```
2. 创建索引
```
IndexService indexService = new IndexServiceImpl();
/** 构建索引的接口
* List:model的集合
* Class: model的class
*
* return boolean
**/
indexService.buildIndex(List, Class)
```
3.查找
```
ArrayList<SearchParamModel> searchParams = new ArrayList<>();
/**添加查询的条件,如果有多个查询条件,则添加SearchParamModel
* fieldName:需要查找的字段,即model中的成员变量
* fieldValue:需要查找字段的值,这个不解释
* BooleanType:Lucene中BooleanClause.Occur值,不懂请自行查询资料
**/
searchParams.add(new SearchParamModel(fieldName, fieldValue, BooleanType));
IndexService indexService = new IndexServiceImpl();
/** 查询的接口
* searchParams:不解释
* Class: model的class
*
* return model的集合
**/
List objs = indexService.search(searchParams, Class);
```
IndexService中还支持update, delete和分页查找的方法,请自行查阅代码。
觉得不错,请点个赞吧。
社区日报 第187期 (2018-02-12)
社区日报 • kimichen123 发表了文章 • 0 个评论 • 1771 次浏览 • 2018-02-12 08:00
http://t.cn/RR5w7uJ
2.kibana-6建立可视化图表前的前期准备工作。
http://t.cn/RR5Z4du
3.使用Curator管理Elasticsearch的索引。
http://t.cn/RR5Zxso
编辑:叮咚光军
归档:https://elasticsearch.cn/article/499
订阅:https://tinyletter.com/elastic-daily
es 设计mapping时 如何创建 嵌套型实体:一个实体里面有一个list
回复Elasticsearch • PhoebM 回复了问题 • 1 人关注 • 1 个回复 • 6599 次浏览 • 2018-02-11 20:02
transportClient api : 字段折叠后按照数量排序
回复Elasticsearch • dlliwei 发起了问题 • 1 人关注 • 0 个回复 • 2849 次浏览 • 2018-02-11 16:22
elasticsearch源码导入intellij
Elasticsearch • zhangguojun 发表了文章 • 1 个评论 • 3406 次浏览 • 2018-02-11 15:11
windows10,jdk1.8,elasticsearch-6.1.3,gradle-4.5,intellij
过程:
1:从github上下载elasticsearch-6.1.3版本,并且解压
2:安装gradle配置环境变量
3:进入elasticsearch目录执行:gradle idea命令
4:使用intellij导入elasticsearch项目
windows10,jdk1.8,elasticsearch-6.1.3,gradle-4.5,intellij
过程:
1:从github上下载elasticsearch-6.1.3版本,并且解压
2:安装gradle配置环境变量
3:进入elasticsearch目录执行:gradle idea命令
4:使用intellij导入elasticsearch项目
logstash消费redis集群中数据
Logstash • zhangyufu 回复了问题 • 4 人关注 • 3 个回复 • 5759 次浏览 • 2018-02-12 08:48
磁盘读写速度和IO使用率对ES的稳定性是否有影响?
Elasticsearch • locatelli 回复了问题 • 4 人关注 • 1 个回复 • 6662 次浏览 • 2018-02-12 04:53
org.elasticsearch.index.mapper.MapperParsingException: No type specified for field
回复Elasticsearch • DeepRedApple 发起了问题 • 1 人关注 • 0 个回复 • 5642 次浏览 • 2018-02-11 11:04
谁推荐一本关于es以及lucene的书籍,深入学习es
Elasticsearch • code4j 回复了问题 • 6 人关注 • 4 个回复 • 19983 次浏览 • 2019-08-05 10:35
请问当结果集比较大或者bucket数量太多时,使用dateHistogram,terms进行聚合分析如何优化?
Elasticsearch • laoyang360 回复了问题 • 4 人关注 • 2 个回复 • 6059 次浏览 • 2018-02-11 19:38
社区日报 第186期 (2018-02-11)
社区日报 • 至尊宝 发表了文章 • 0 个评论 • 1908 次浏览 • 2018-02-11 09:06
http://t.cn/RRbOoII
2.分析3个月的未读电子邮件。
http://t.cn/RRbMyR8
3.(自备梯子)使用ELK堆栈实现客户智能。
http://t.cn/RRbx2XL
编辑:至尊宝
归档:https://elasticsearch.cn/article/497
订阅:https://tinyletter.com/elastic-daily
logstash 日志里老是有错误
Logstash • haiying 回复了问题 • 3 人关注 • 3 个回复 • 9992 次浏览 • 2018-06-29 12:03
在使用es2.4版本过程中关于映射的问题!
回复Elasticsearch • ajaq454 回复了问题 • 1 人关注 • 1 个回复 • 2405 次浏览 • 2018-02-10 15:44
推荐indies_view 插件
Kibana • truman.p.du 发表了文章 • 1 个评论 • 3451 次浏览 • 2018-02-10 15:05
indies_view
[https://github.com/TrumanDu/indices_view](https://github.com/TrumanDu/indices_view)
An awesome kibana plugin for view indies!
这个是一个可以查看indices 相关信息的kibana plugin ,欢迎大家使用,或者提出宝贵的经验
---
Screenshots
Reg pattern
```
- /[^a-z] $/
- /[\d]{4}[-|.|/][\d]{1,2}[-|.|/][\d]{1,2}/
```
Development
See the [kibana contributing guide](https://github.com/elastic/kib ... ING.md) for instructions setting up your development environment. Once you have completed that, use the following npm tasks.
npm start
Start kibana and have it include this plugin
npm start -- --config kibana.yml
You can pass any argument that you would normally send tobin/kibanaby putting them after--when runningnpm start
npm run build
Build a distributable archive
npm run test:browser
Run the browser tests in a real web browser
npm run test:server
Run the server tests using mocha
For more information about any of these commands runnpm run ${task} -- --help.
Deploy
important : edit this plugin version and kibana.version to you kibana version in package.json
npm installnpm run build
Build a distributable archive
Install
- cp to docker container
$ sudo docker cp ****.zip id:/****.zip
- install to kibana
$bin/kibana-plugin install file:///****.zip
社区日报 第185期 (2018-02-10)
社区日报 • elk123 发表了文章 • 0 个评论 • 2154 次浏览 • 2018-02-10 11:29
- Elasticsearch与Hbase特性对比。
http://t.cn/RRyM1vm - 将Elasticsearch作为Hive的存储?
http://t.cn/RRyxDNZ - 基于Elasticsearch实现搜索推荐
http://t.cn/RRyJiHx





