Elasticsearch的javaAPI之get,delete,bulk
Elsasticsearch的javaAPI之get
get API同意依据其id获得指定index中的基于json document。以下的样例得到一个JSON document(index为twitter,type为tweet,id为价值1)
GetResponse response = client.prepareGet("twitter", "tweet", "1").execute().actionGet();
在get操作的很多其它信息,能够查看REST get docs
线程操作
Get API同意你设置线程来运行操作。这样实际将运行API上运行的是同样的节点(API上运行一个分配在同一server的shard上)。
选择一个不同的线程上运行操作,或调用线程上运行它(注意,API仍然异步)。 默认情况下,
被设置为
operationThreadedtrue,这意味着操作是由不同的线程上运行以下是一个演示样例,设置为false:GetResponse response = client.prepareGet("twitter", "tweet", "1").setOperationThreaded(false).execute().actionGet();Elsasticsearch的javaAPI之delete
delete API同意依据其id删除指定index中的json document。以下的样例:删除一个JSON document(index为twitter,type为tweet,id为价值1)
DeleteResponse response = client.prepareDelete("twitter", "tweet", "1").execute().actionGet();
在删除操作的很多其它信息,查看delete API docs。
线程操作
Delete API同意你设置线程来运行操作。这样实际姜运行API上运行的是同样的节点(API上运行一个分配在同一server的shard上)。
选择一个不同的线程上运行操作,或调用线程上运行它(注意,API仍然异步)。
默认情况下,
被设置为
operationThreadedtrue,这意味着操作是由不同的线程上运行以下是一个演示样例,设置为false:DeleteResponse response = client.prepareDelete("twitter", "tweet", "1").setOperationThreaded(false).execute().actionGet();Elasticsearch的javaAPI之bulk
Bulk API能够用来在一个请求中,检索和删除多条数据,以下是一个样例:
import
static org.elasticsearch.common.xcontent.XContentFactory.*;
BulkRequestBuilder bulkRequest
= client.prepareBulk();
// either use client#prepare, or use Requests# to directly build index/delete requests
bulkRequest.add(client.prepareIndex("twitter",
"tweet",
"1")
.setSource(jsonBuilder()
.startObject()
.field("user",
"kimchy")
.field("postDate",
new
Date())
.field("message",
"trying out Elasticsearch")
.endObject()
)
);
bulkRequest.add(client.prepareIndex("twitter",
"tweet",
"2")
.setSource(jsonBuilder()
.startObject()
.field("user",
"kimchy")
.field("postDate",
new
Date())
.field("message",
"another post")
.endObject()
)
);
BulkResponse bulkResponse
= bulkRequest.execute().actionGet();
if
(bulkResponse.hasFailures())
{
// process failures by iterating through each bulk response item
}
原文http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/get.html
http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/delete.html
http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/bulk.html翻译欠佳。希望不会对大家造成误导
Elasticsearch的javaAPI之get,delete,bulk的更多相关文章
- ElasticSearch的javaAPI之Client
翻译的原文:http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/client.html#node-c ...
- Elasticsearch的javaAPI之percolator
Elasticsearch的javaAPI之percolator percolator同意一个在index中注冊queries,然后发送包括doc的请求,返回得到在index中注冊过的而且匹配doc的 ...
- elasticsearch的javaAPI之query
elasticsearch的javaAPI之query API the Search API同意运行一个搜索查询,返回一个与查询匹配的结果(hits). 它能够在跨一个或多个index上运行, 或者一 ...
- Elasticsearch的javaAPI之query dsl-queries
Elasticsearch的javaAPI之query dsl-queries 和rest query dsl一样,elasticsearch提供了一个完整的Java query dsl. 查询建造者 ...
- elasticsearch的javaAPI之index
Index API 原文:http://www.elasticsearch.org/guide/en/elasticsearch/client/java-api/current/index_.html ...
- ElasticSearch(十一)批量CURD bulk
1.bulk语法 POST /_bulk { "delete": { "_index": "test_index", "_type ...
- Elasticsearch增删改查 之 —— Delete删除
删除文档也算是常用的操作了...如果把Elasticsearch当做一款普通的数据库,那么删除操作自然就很常用了.如果仅仅是全文检索,可能就不会太常用到删除. Delete API 删除API,可以根 ...
- java操作elasticsearch实现批量添加数据(bulk)
java操作elasticsearch实现批量添加主要使用了bulk 代码如下: //bulk批量操作(批量添加) @Test public void test7() throws IOExcepti ...
- Elasticsearch的JavaAPI
获取客户端对象 public class App { private TransportClient client; //获取客户端对象 @Before public void getClinet() ...
随机推荐
- Synchronized和Lock, 以及自旋锁 Spin Lock, Ticket Spin Lock, MCS Spin Lock, CLH Spin Lock
Synchronized和Lock synchronized是一个关键字, Lock是一个接口, 对应有多种实现. 使用synchronized进行同步和使用Lock进行同步的区别 使用synchro ...
- R语言-查找满足条件的数并获取索引
1.在R语言中,怎样找到满足条件的数呢? 比如给定一个向量c2.要求找到数值大于0的数: > c2 [1] 0.00 0.00 0.00 0.00 0.00 0.00 0.06 0.09 0. ...
- Android API之android.provider.ContactsContract.RawContacts
android.provider.ContactsContract.RawContacts Constants for the raw contacts table, which contains o ...
- PHP关于进程池的优化
本文打算从另一个角度来讨论问题,教大家如何配置高效的环境,如此同样能够达到优化的目的. pool 一个让人沮丧的消息是绝大多数 PHP 程序员都忽视了池的价值.这里所说的池可不是指数据库连接池之类的东 ...
- springmvc+spring框架
jar包 com.springsource.javax.validation-1.0.0.GA.jar com.springsource.org.aopalliance-1.0.0.jar com.s ...
- leetcode185 Department Top Three Salaries
Employee表存储员工姓名.员工所在公寓.员工工资 Department表存储公寓id 评选出各个公寓的工资前三名的员工. 遇到的问题如下: limit,in等语句不能用在嵌套select语句中, ...
- iOS - CodeReview 代码评审
1.CodeReview Code Review 中文应该译作 "代码审查" 或是 "代码评审",这是一个流程,当开发人员写好代码后,需要让别人来 review ...
- 基于Vuejs实现 Skeleton Loading 骨架图
原文地址:https://cloud.tencent.com/developer/article/1006169 https://mp.weixin.qq.com/s/qmyn6mGrO6hRKuvK ...
- 实战:MySQL Sending data导致查询很慢的问题详细分析(转)
这两天帮忙定位一个MySQL查询很慢的问题,定位过程综合各种方法.理论.工具,很有代表性,分享给大家作为新年礼物:) [问题现象] 使用sphinx支持倒排索引,但sphinx从mysql查询源数据的 ...
- 免费申请 Github 私有仓库--学生和教育人士的福利
免费申请 Github 私有仓库 -学生和教育人士的福利 Github 是全球知名的软件项目托管网站.在 Github 创建私有仓库是需要收费的,收费方案有多种,费用最小的方案是每月 7 美元的“微型 ...