Elsasticsearch's Javaapi get
The Get API allows JSON-based document in the specified index to be obtained based on its ID. The following example obtains a JSON document (index of Twitter,type is tweet,id for value 1)
< Span class= "Typ" >getresponse response = client prepareget "Twitter" "tweet" "1" )
execute ()
actionget
();
For more information on the get operation, you can view rest get docs
Threading Operations
The Get API allows you to set up threads to perform operations so that the actual execution of the API is performed on the same node (the API executes on a shard that is assigned on the same server).
Select a different thread to perform the operation on, or execute it on the calling thread (note that the API is still asynchronous). By default, operationThreaded
The actions that are set to true
,
This mean that the operation is performed on a different thread are as follows an example, set to False:
GetResponse response = Client.prepareget ("Twitter", "tweet", "1")
. setoperationthreaded (False)
. Execute ()
. Actionget ();
Elsasticsearch's Javaapi Delete
The Delete API allows you to delete the JSON document in the specified index based on its ID. The following example: Delete a JSON document (index is twitter,type to Tweet,id for value 1)
< Span class= "Typ" >deleteresponse response = client preparedelete "Twitter" "tweet" "1" )
execute ()
actionget
();
For more information on the delete operation, view the delete API docs.
Threading Operations
The Delete API allows you to set up threads to perform operations so that the actual ginger execution API executes on the same node (the API executes on a shard that is assigned on the same server).
Select a different thread to perform the operation on, or execute it on the calling thread (note that the API is still asynchronous). By default, operationThreaded
The actions that are set to true
,
This mean that the operation is performed on a different thread are as follows an example, set to False:
Deleteresponse response = Client.preparedelete ("Twitter", "tweet", "1")
. setoperationthreaded (False)
. Execute ()
. Actionget ();
The bulk of the javaapi of Elasticsearch
The Bulk API can be used to retrieve and delete multiple data in a single request, and here is an example:
Import Static org . Elasticsearch . Common . xcontent . xcontentfactory .*;
Bulkrequestbuilderbulkrequest=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 ()
)
);
BulkresponseBulkresponse=bulkrequest.Execute().Actionget();
if ( Bulkresponse . Hasfailures ()) {
//process failures by iterating through per bulk response item
}
Original 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
I hope that the translation is not misleading.
The get,delete,bulk of the Javaapi of Elasticsearch