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() ...
随机推荐
- 打开Activity时,不自动显示(弹出)虚拟键盘
打开Activity时,不自动显示(弹出)虚拟键盘 在AndroidManifest.xml文件中<activity>标签中添加属性 android:windowSoftInputMode ...
- jQuery+PHP动态显示(项目)实时时间和倒计时
jQuery动态显示当前时间: html代码:<div id="current_time"></div> setInterval()使用:setInt ...
- iOS AppIcon尺寸和上传ITunes构建版本尺寸和iPhone屏幕尺寸
避免忘记. 记录一下 App Icon: 29X2940X4058X5876X7687X8780X80120X120152X152167X167180X180 ITunes构建版本: 1242 x 2 ...
- HDUOJ------2492Ping pong
Ping pong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- 【LeetCode】142. Linked List Cycle II (2 solutions)
Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cyc ...
- EditPlus正则表达式中英文详解(附常用事例操作)
http://www.cnblogs.com/JustinYoung/articles/editplus_regular_expression.html EditPlus正则表达式中英文详解 \t T ...
- Access数据库的连接字符串
<!-- Access2007 --> Provider=Microsoft.ACE.OLEDB.12.0;Data Source=data\myAccess_db.accdb;Persi ...
- Linux时间子系统(十二) periodic tick
一.tick device概念介绍 1.数据结构 在内核中,使用struct tick_device来抽象系统中的tick设备,如下: struct tick_device { struct ...
- 杭电 1800 Flying to the Mars(贪心)
http://acm.hdu.edu.cn/showproblem.php?pid=1800 Flying to the Mars Time Limit: 5000/1000 MS (Java/Oth ...
- 使用Xfire发布WebService接口遇到的问题:
问题一: log4j:WARN No appenders could be found for logger (org.codehaus.xfire.transport.DefaultTranspor ...