分布式搜索Elasticsearch——检索一条记录
2013-05-09 18:59
507 查看
分布式搜索Elasticsearch——创建索引一文中提到如何创建索引,本文讲述如何检索一条记录,也就是ES中的Get。
在创建索引时,我们根据IndexResponse,得到了index、type和id,Get一条记录的方法很简单:
分布式搜索Elasticsearch——创建索引一文中提到如何将一个实体转化为Json字符串,我们推荐的方法是使用Jackson,那么,在Get得到Response后,也使用Jackson将Json字符串转化为你的实体:
在创建索引时,我们根据IndexResponse,得到了index、type和id,Get一条记录的方法很简单:
GetResponse getResponse = client.prepareGet(index, type, id).execute().actionGet();
分布式搜索Elasticsearch——创建索引一文中提到如何将一个实体转化为Json字符串,我们推荐的方法是使用Jackson,那么,在Get得到Response后,也使用Jackson将Json字符串转化为你的实体:
Person newPerson = mapper.readValue(getResponse.getSourceAsString(), Person.class);
相关文章推荐
- .NET 分布式 搜索 elasticsearch.net NEST
- 分布式搜索Elasticsearch——概述
- 分布式搜索Elasticsearch——配置
- 分布式搜索Elasticsearch——项目过程(一)
- 分布式搜索Elasticsearch——配置
- 分布式搜索Elasticsearch——创建客户端(五)
- 分布式搜索Elasticsearch——QueryBuilders.matchPhrasePrefixQuery
- 分布式搜索方案选型之五(终篇):Elasticsearch
- 分布式搜索Elasticsearch——安装
- 分布式搜索Elasticsearch——创建客户端(二)
- 开源分布式搜索平台ELK(Elasticsearch+Logstash+Kibana)+Redis+Syslog-ng实现日志实时搜索
- 分布式搜索Elasticsearch——项目过程(二)
- 分布式搜索Elasticsearch——配置
- 分布式搜索Elasticsearch——创建客户端(三)
- 分布式搜索Elasticsearch——QueryBuilders.matchQuery
- 开源分布式搜索平台ELK(Elasticsearch+Logstash+Kibana)入门学习资源索引
- 分布式搜索Elasticsearch——QueryBuilders.termQuery
- 分布式搜索Elasticsearch——QueryBuilders.matchPhrasePrefixQuery
- 分布式搜索Elasticsearch——配置
- 分布式搜索Elasticsearch——创建客户端(四)