亲,只收二进制

一个简单的Lucene工具类,通过注释的方式来配置构建索引的字段。提供新建索引、查找、删除、更新方法,支持分页。

Lucenepengshaojie 发表了文章 • 6 个评论 • 4230 次浏览 • 2018-02-12 10:23 • 来自相关话题

代码地址:https://gitee.com/shaojiepeng/wsm-lucene
 ### 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同义,不懂请自行查询资料
```

173117_4fa2ac08_980808.png



2. 创建索引
```

IndexService indexService = new IndexServiceImpl();
/** 构建索引的接口
 * List:model的集合
 * Class: model的class
 *
 * return boolean
**/
indexService.buildIndex(List, Class)
```

173148_bb488cf0_980808.png



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);
```

173219_367ef1d0_980808.png




IndexService中还支持update, delete和分页查找的方法,请自行查阅代码。


觉得不错,请点个赞吧。

社区日报 第187期 (2018-02-12)

社区日报kimichen123 发表了文章 • 0 个评论 • 1771 次浏览 • 2018-02-12 08:00 • 来自相关话题

1.Scrapy分布式爬虫打造搜索引擎系列。
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

回复

ElasticsearchPhoebM 回复了问题 • 1 人关注 • 1 个回复 • 6599 次浏览 • 2018-02-11 20:02 • 来自相关话题

transportClient api : 字段折叠后按照数量排序

回复

Elasticsearchdlliwei 发起了问题 • 1 人关注 • 0 个回复 • 2849 次浏览 • 2018-02-11 16:22 • 来自相关话题

elasticsearch源码导入intellij

Elasticsearchzhangguojun 发表了文章 • 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集群中数据

Logstashzhangyufu 回复了问题 • 4 人关注 • 3 个回复 • 5759 次浏览 • 2018-02-12 08:48 • 来自相关话题

磁盘读写速度和IO使用率对ES的稳定性是否有影响?

Elasticsearchlocatelli 回复了问题 • 4 人关注 • 1 个回复 • 6662 次浏览 • 2018-02-12 04:53 • 来自相关话题

org.elasticsearch.index.mapper.MapperParsingException: No type specified for field

回复

ElasticsearchDeepRedApple 发起了问题 • 1 人关注 • 0 个回复 • 5642 次浏览 • 2018-02-11 11:04 • 来自相关话题

谁推荐一本关于es以及lucene的书籍,深入学习es

Elasticsearchcode4j 回复了问题 • 6 人关注 • 4 个回复 • 19983 次浏览 • 2019-08-05 10:35 • 来自相关话题

请问当结果集比较大或者bucket数量太多时,使用dateHistogram,terms进行聚合分析如何优化?

Elasticsearchlaoyang360 回复了问题 • 4 人关注 • 2 个回复 • 6059 次浏览 • 2018-02-11 19:38 • 来自相关话题

社区日报 第186期 (2018-02-11)

社区日报至尊宝 发表了文章 • 0 个评论 • 1908 次浏览 • 2018-02-11 09:06 • 来自相关话题

1.如何用Kibana监控AdroitLogic ESB(UltraESB-X)。
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 日志里老是有错误

Logstashhaiying 回复了问题 • 3 人关注 • 3 个回复 • 9992 次浏览 • 2018-06-29 12:03 • 来自相关话题

在使用es2.4版本过程中关于映射的问题!

回复

Elasticsearchajaq454 回复了问题 • 1 人关注 • 1 个回复 • 2405 次浏览 • 2018-02-10 15:44 • 来自相关话题

推荐indies_view 插件

Kibanatruman.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


indices_view.gif



Reg pattern


```

  1. /[^a-z] $/
  2. /[\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 to bin/kibana by putting them after -- when running npm 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 run npm run ${task} -- --help.

      Deploy


      important : edit this plugin version and kibana.version to you kibana version in package.json

    • npm install
    • npm run build

      Build a distributable archive

      Install


  3. cp to docker container

    $ sudo docker cp ****.zip id:/****.zip

  4. install to kibana

    $bin/kibana-plugin install file:///****.zip

社区日报 第185期 (2018-02-10)

社区日报elk123 发表了文章 • 0 个评论 • 2154 次浏览 • 2018-02-10 11:29 • 来自相关话题

  1. Elasticsearch与Hbase特性对比。
    http://t.cn/RRyM1vm
  2. 将Elasticsearch作为Hive的存储?
    http://t.cn/RRyxDNZ
  3. 基于Elasticsearch实现搜索推荐
    http://t.cn/RRyJiHx