org.elasticsearch.client.transport
Class TransportClient

java.lang.Object
  extended by org.elasticsearch.client.support.AbstractClient
      extended by org.elasticsearch.client.transport.TransportClient
All Implemented Interfaces:
Client, InternalClient

public class TransportClient
extends AbstractClient

The transport client allows to create a client that is not part of the cluster, but simply connects to one or more nodes directly by adding their respective addresses using addTransportAddress(org.elasticsearch.common.transport.TransportAddress).

The transport client important modules used is the TransportModule which is started in client mode (only connects, no bind).


Constructor Summary
TransportClient()
          Constructs a new transport client with settings loaded either from the classpath or the file system (the elasticsearch.(yml|json) files optionally prefixed with config/).
TransportClient(Settings.Builder settings)
          Constructs a new transport client with explicit settings and settings loaded either from the classpath or the file system (the elasticsearch.(yml|json) files optionally prefixed with config/).
TransportClient(Settings.Builder settings, boolean loadConfigSettings)
          Constructs a new transport client with the provided settings and the ability to control if settings will be loaded from the classpath / file system (the elasticsearch.(yml|json) files optionally prefixed with config/).
TransportClient(Settings settings)
          Constructs a new transport client with explicit settings and settings loaded either from the classpath or the file system (the elasticsearch.(yml|json) files optionally prefixed with config/).
TransportClient(Settings pSettings, boolean loadConfigSettings)
          Constructs a new transport client with the provided settings and the ability to control if settings will be loaded from the classpath / file system (the elasticsearch.(yml|json) files optionally prefixed with config/).
 
Method Summary
 TransportClient addTransportAddress(TransportAddress transportAddress)
          Adds a transport address that will be used to connect to.
 TransportClient addTransportAddresses(TransportAddress... transportAddress)
          Adds a list of transport addresses that will be used to connect to.
 AdminClient admin()
          The admin client that can be used to perform administrative operations.
 ActionFuture<BulkResponse> bulk(BulkRequest request)
          Executes a bulk of index / delete operations.
 void bulk(BulkRequest request, ActionListener<BulkResponse> listener)
          Executes a bulk of index / delete operations.
 void close()
          Closes the client.
 com.google.common.collect.ImmutableList<DiscoveryNode> connectedNodes()
          Returns the current connected transport nodes that this client will use.
 ActionFuture<CountResponse> count(CountRequest request)
          A count of all the documents matching a specific query.
 void count(CountRequest request, ActionListener<CountResponse> listener)
          A count of all the documents matching a specific query.
 ActionFuture<DeleteResponse> delete(DeleteRequest request)
          Deletes a document from the index based on the index, type and id.
 void delete(DeleteRequest request, ActionListener<DeleteResponse> listener)
          Deletes a document from the index based on the index, type and id.
 ActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request)
          Deletes all documents from one or more indices based on a query.
 void deleteByQuery(DeleteByQueryRequest request, ActionListener<DeleteByQueryResponse> listener)
          Deletes all documents from one or more indices based on a query.
<Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response>>
ActionFuture<Response>
execute(Action<Request,Response,RequestBuilder> action, Request request)
          Executes a generic action, denoted by an Action.
<Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response>>
void
execute(Action<Request,Response,RequestBuilder> action, Request request, ActionListener<Response> listener)
          Executes a generic action, denoted by an Action.
 ActionFuture<ExplainResponse> explain(ExplainRequest request)
          Computes a score explanation for the specified request.
 void explain(ExplainRequest request, ActionListener<ExplainResponse> listener)
          Computes a score explanation for the specified request.
 ActionFuture<GetResponse> get(GetRequest request)
          Gets the document that was indexed from an index with a type and id.
 void get(GetRequest request, ActionListener<GetResponse> listener)
          Gets the document that was indexed from an index with a type and id.
 ActionFuture<IndexResponse> index(IndexRequest request)
          Index a JSON source associated with a given index and type.
 void index(IndexRequest request, ActionListener<IndexResponse> listener)
          Index a document associated with a given index and type.
 com.google.common.collect.ImmutableList<DiscoveryNode> listedNodes()
          Returns the listed nodes in the transport client (ones added to it).
 ActionFuture<SearchResponse> moreLikeThis(MoreLikeThisRequest request)
          A more like this action to search for documents that are "like" a specific document.
 void moreLikeThis(MoreLikeThisRequest request, ActionListener<SearchResponse> listener)
          A more like this action to search for documents that are "like" a specific document.
 ActionFuture<MultiGetResponse> multiGet(MultiGetRequest request)
          Multi get documents.
 void multiGet(MultiGetRequest request, ActionListener<MultiGetResponse> listener)
          Multi get documents.
 ActionFuture<MultiSearchResponse> multiSearch(MultiSearchRequest request)
          Performs multiple search requests.
 void multiSearch(MultiSearchRequest request, ActionListener<MultiSearchResponse> listener)
          Performs multiple search requests.
 ActionFuture<PercolateResponse> percolate(PercolateRequest request)
          Percolates a request returning the matches documents.
 void percolate(PercolateRequest request, ActionListener<PercolateResponse> listener)
          Percolates a request returning the matches documents.
 TransportClient removeTransportAddress(TransportAddress transportAddress)
          Removes a transport address from the list of transport addresses that are used to connect to.
 ActionFuture<SearchResponse> search(SearchRequest request)
          Search across one or more indices and one or more types with a query.
 void search(SearchRequest request, ActionListener<SearchResponse> listener)
          Search across one or more indices and one or more types with a query.
 ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request)
          A search scroll request to continue searching a previous scrollable search request.
 void searchScroll(SearchScrollRequest request, ActionListener<SearchResponse> listener)
          A search scroll request to continue searching a previous scrollable search request.
 Settings settings()
           
 ThreadPool threadPool()
           
 com.google.common.collect.ImmutableList<TransportAddress> transportAddresses()
          Returns the current registered transport addresses to use (added using addTransportAddress(org.elasticsearch.common.transport.TransportAddress).
 ActionFuture<UpdateResponse> update(UpdateRequest request)
          Updates a document based on a script.
 void update(UpdateRequest request, ActionListener<UpdateResponse> listener)
          Updates a document based on a script.
 
Methods inherited from class org.elasticsearch.client.support.AbstractClient
prepareBulk, prepareCount, prepareDelete, prepareDelete, prepareDeleteByQuery, prepareExecute, prepareExplain, prepareGet, prepareGet, prepareIndex, prepareIndex, prepareIndex, prepareMoreLikeThis, prepareMultiGet, prepareMultiSearch, preparePercolate, prepareSearch, prepareSearchScroll, prepareUpdate, prepareUpdate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransportClient

public TransportClient()
                throws ElasticSearchException
Constructs a new transport client with settings loaded either from the classpath or the file system (the elasticsearch.(yml|json) files optionally prefixed with config/).

Throws:
ElasticSearchException

TransportClient

public TransportClient(Settings settings)
Constructs a new transport client with explicit settings and settings loaded either from the classpath or the file system (the elasticsearch.(yml|json) files optionally prefixed with config/).


TransportClient

public TransportClient(Settings.Builder settings)
Constructs a new transport client with explicit settings and settings loaded either from the classpath or the file system (the elasticsearch.(yml|json) files optionally prefixed with config/).


TransportClient

public TransportClient(Settings.Builder settings,
                       boolean loadConfigSettings)
                throws ElasticSearchException
Constructs a new transport client with the provided settings and the ability to control if settings will be loaded from the classpath / file system (the elasticsearch.(yml|json) files optionally prefixed with config/).

Parameters:
settings - The explicit settings.
loadConfigSettings - true if settings should be loaded from the classpath/file system.
Throws:
ElasticSearchException

TransportClient

public TransportClient(Settings pSettings,
                       boolean loadConfigSettings)
                throws ElasticSearchException
Constructs a new transport client with the provided settings and the ability to control if settings will be loaded from the classpath / file system (the elasticsearch.(yml|json) files optionally prefixed with config/).

Parameters:
pSettings - The explicit settings.
loadConfigSettings - true if settings should be loaded from the classpath/file system.
Throws:
ElasticSearchException
Method Detail

transportAddresses

public com.google.common.collect.ImmutableList<TransportAddress> transportAddresses()
Returns the current registered transport addresses to use (added using addTransportAddress(org.elasticsearch.common.transport.TransportAddress).


connectedNodes

public com.google.common.collect.ImmutableList<DiscoveryNode> connectedNodes()
Returns the current connected transport nodes that this client will use.

The nodes include all the nodes that are currently alive based on the transport addresses provided.


listedNodes

public com.google.common.collect.ImmutableList<DiscoveryNode> listedNodes()
Returns the listed nodes in the transport client (ones added to it).


addTransportAddress

public TransportClient addTransportAddress(TransportAddress transportAddress)
Adds a transport address that will be used to connect to.

The Node this transport address represents will be used if its possible to connect to it. If it is unavailable, it will be automatically connected to once it is up.

In order to get the list of all the current connected nodes, please see connectedNodes().


addTransportAddresses

public TransportClient addTransportAddresses(TransportAddress... transportAddress)
Adds a list of transport addresses that will be used to connect to.

The Node this transport address represents will be used if its possible to connect to it. If it is unavailable, it will be automatically connected to once it is up.

In order to get the list of all the current connected nodes, please see connectedNodes().


removeTransportAddress

public TransportClient removeTransportAddress(TransportAddress transportAddress)
Removes a transport address from the list of transport addresses that are used to connect to.


close

public void close()
Closes the client.


settings

public Settings settings()

threadPool

public ThreadPool threadPool()

admin

public AdminClient admin()
Description copied from interface: Client
The admin client that can be used to perform administrative operations.


execute

public <Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response>> ActionFuture<Response> execute(Action<Request,Response,RequestBuilder> action,
                                                                                                                                                                    Request request)
Description copied from interface: Client
Executes a generic action, denoted by an Action.

Type Parameters:
Request - Teh request type.
Response - the response type.
RequestBuilder - The request builder type.
Parameters:
action - The action type to execute.
request - The action request.
Returns:
A future allowing to get back the response.

execute

public <Request extends ActionRequest,Response extends ActionResponse,RequestBuilder extends ActionRequestBuilder<Request,Response>> void execute(Action<Request,Response,RequestBuilder> action,
                                                                                                                                                  Request request,
                                                                                                                                                  ActionListener<Response> listener)
Description copied from interface: Client
Executes a generic action, denoted by an Action.

Type Parameters:
Request - The request type.
Response - The response type.
RequestBuilder - The request builder type.
Parameters:
action - The action type to execute.
request - Teh action request.
listener - The listener to receive the response back.

index

public ActionFuture<IndexResponse> index(IndexRequest request)
Description copied from interface: Client
Index a JSON source associated with a given index and type.

The id is optional, if it is not provided, one will be generated automatically.

Specified by:
index in interface Client
Overrides:
index in class AbstractClient
Parameters:
request - The index request
Returns:
The result future
See Also:
Requests.indexRequest(String)

index

public void index(IndexRequest request,
                  ActionListener<IndexResponse> listener)
Description copied from interface: Client
Index a document associated with a given index and type.

The id is optional, if it is not provided, one will be generated automatically.

Specified by:
index in interface Client
Overrides:
index in class AbstractClient
Parameters:
request - The index request
listener - A listener to be notified with a result
See Also:
Requests.indexRequest(String)

update

public ActionFuture<UpdateResponse> update(UpdateRequest request)
Description copied from interface: Client
Updates a document based on a script.

Specified by:
update in interface Client
Overrides:
update in class AbstractClient
Parameters:
request - The update request
Returns:
The result future

update

public void update(UpdateRequest request,
                   ActionListener<UpdateResponse> listener)
Description copied from interface: Client
Updates a document based on a script.

Specified by:
update in interface Client
Overrides:
update in class AbstractClient
Parameters:
request - The update request
listener - A listener to be notified with a result

delete

public ActionFuture<DeleteResponse> delete(DeleteRequest request)
Description copied from interface: Client
Deletes a document from the index based on the index, type and id.

Specified by:
delete in interface Client
Overrides:
delete in class AbstractClient
Parameters:
request - The delete request
Returns:
The result future
See Also:
Requests.deleteRequest(String)

delete

public void delete(DeleteRequest request,
                   ActionListener<DeleteResponse> listener)
Description copied from interface: Client
Deletes a document from the index based on the index, type and id.

Specified by:
delete in interface Client
Overrides:
delete in class AbstractClient
Parameters:
request - The delete request
listener - A listener to be notified with a result
See Also:
Requests.deleteRequest(String)

bulk

public ActionFuture<BulkResponse> bulk(BulkRequest request)
Description copied from interface: Client
Executes a bulk of index / delete operations.

Specified by:
bulk in interface Client
Overrides:
bulk in class AbstractClient
Parameters:
request - The bulk request
Returns:
The result future
See Also:
Requests.bulkRequest()

bulk

public void bulk(BulkRequest request,
                 ActionListener<BulkResponse> listener)
Description copied from interface: Client
Executes a bulk of index / delete operations.

Specified by:
bulk in interface Client
Overrides:
bulk in class AbstractClient
Parameters:
request - The bulk request
listener - A listener to be notified with a result
See Also:
Requests.bulkRequest()

deleteByQuery

public ActionFuture<DeleteByQueryResponse> deleteByQuery(DeleteByQueryRequest request)
Description copied from interface: Client
Deletes all documents from one or more indices based on a query.

Specified by:
deleteByQuery in interface Client
Overrides:
deleteByQuery in class AbstractClient
Parameters:
request - The delete by query request
Returns:
The result future
See Also:
Requests.deleteByQueryRequest(String...)

deleteByQuery

public void deleteByQuery(DeleteByQueryRequest request,
                          ActionListener<DeleteByQueryResponse> listener)
Description copied from interface: Client
Deletes all documents from one or more indices based on a query.

Specified by:
deleteByQuery in interface Client
Overrides:
deleteByQuery in class AbstractClient
Parameters:
request - The delete by query request
listener - A listener to be notified with a result
See Also:
Requests.deleteByQueryRequest(String...)

get

public ActionFuture<GetResponse> get(GetRequest request)
Description copied from interface: Client
Gets the document that was indexed from an index with a type and id.

Specified by:
get in interface Client
Overrides:
get in class AbstractClient
Parameters:
request - The get request
Returns:
The result future
See Also:
Requests.getRequest(String)

get

public void get(GetRequest request,
                ActionListener<GetResponse> listener)
Description copied from interface: Client
Gets the document that was indexed from an index with a type and id.

Specified by:
get in interface Client
Overrides:
get in class AbstractClient
Parameters:
request - The get request
listener - A listener to be notified with a result
See Also:
Requests.getRequest(String)

multiGet

public ActionFuture<MultiGetResponse> multiGet(MultiGetRequest request)
Description copied from interface: Client
Multi get documents.

Specified by:
multiGet in interface Client
Overrides:
multiGet in class AbstractClient

multiGet

public void multiGet(MultiGetRequest request,
                     ActionListener<MultiGetResponse> listener)
Description copied from interface: Client
Multi get documents.

Specified by:
multiGet in interface Client
Overrides:
multiGet in class AbstractClient

count

public ActionFuture<CountResponse> count(CountRequest request)
Description copied from interface: Client
A count of all the documents matching a specific query.

Specified by:
count in interface Client
Overrides:
count in class AbstractClient
Parameters:
request - The count request
Returns:
The result future
See Also:
Requests.countRequest(String...)

count

public void count(CountRequest request,
                  ActionListener<CountResponse> listener)
Description copied from interface: Client
A count of all the documents matching a specific query.

Specified by:
count in interface Client
Overrides:
count in class AbstractClient
Parameters:
request - The count request
listener - A listener to be notified of the result
See Also:
Requests.countRequest(String...)

search

public ActionFuture<SearchResponse> search(SearchRequest request)
Description copied from interface: Client
Search across one or more indices and one or more types with a query.

Specified by:
search in interface Client
Overrides:
search in class AbstractClient
Parameters:
request - The search request
Returns:
The result future
See Also:
Requests.searchRequest(String...)

search

public void search(SearchRequest request,
                   ActionListener<SearchResponse> listener)
Description copied from interface: Client
Search across one or more indices and one or more types with a query.

Specified by:
search in interface Client
Overrides:
search in class AbstractClient
Parameters:
request - The search request
listener - A listener to be notified of the result
See Also:
Requests.searchRequest(String...)

searchScroll

public ActionFuture<SearchResponse> searchScroll(SearchScrollRequest request)
Description copied from interface: Client
A search scroll request to continue searching a previous scrollable search request.

Specified by:
searchScroll in interface Client
Overrides:
searchScroll in class AbstractClient
Parameters:
request - The search scroll request
Returns:
The result future
See Also:
Requests.searchScrollRequest(String)

searchScroll

public void searchScroll(SearchScrollRequest request,
                         ActionListener<SearchResponse> listener)
Description copied from interface: Client
A search scroll request to continue searching a previous scrollable search request.

Specified by:
searchScroll in interface Client
Overrides:
searchScroll in class AbstractClient
Parameters:
request - The search scroll request
listener - A listener to be notified of the result
See Also:
Requests.searchScrollRequest(String)

multiSearch

public ActionFuture<MultiSearchResponse> multiSearch(MultiSearchRequest request)
Description copied from interface: Client
Performs multiple search requests.

Specified by:
multiSearch in interface Client
Overrides:
multiSearch in class AbstractClient

multiSearch

public void multiSearch(MultiSearchRequest request,
                        ActionListener<MultiSearchResponse> listener)
Description copied from interface: Client
Performs multiple search requests.

Specified by:
multiSearch in interface Client
Overrides:
multiSearch in class AbstractClient

moreLikeThis

public ActionFuture<SearchResponse> moreLikeThis(MoreLikeThisRequest request)
Description copied from interface: Client
A more like this action to search for documents that are "like" a specific document.

Specified by:
moreLikeThis in interface Client
Overrides:
moreLikeThis in class AbstractClient
Parameters:
request - The more like this request
Returns:
The response future

moreLikeThis

public void moreLikeThis(MoreLikeThisRequest request,
                         ActionListener<SearchResponse> listener)
Description copied from interface: Client
A more like this action to search for documents that are "like" a specific document.

Specified by:
moreLikeThis in interface Client
Overrides:
moreLikeThis in class AbstractClient
Parameters:
request - The more like this request
listener - A listener to be notified of the result

percolate

public ActionFuture<PercolateResponse> percolate(PercolateRequest request)
Description copied from interface: Client
Percolates a request returning the matches documents.

Specified by:
percolate in interface Client
Overrides:
percolate in class AbstractClient

percolate

public void percolate(PercolateRequest request,
                      ActionListener<PercolateResponse> listener)
Description copied from interface: Client
Percolates a request returning the matches documents.

Specified by:
percolate in interface Client
Overrides:
percolate in class AbstractClient

explain

public ActionFuture<ExplainResponse> explain(ExplainRequest request)
Description copied from interface: Client
Computes a score explanation for the specified request.

Specified by:
explain in interface Client
Overrides:
explain in class AbstractClient
Parameters:
request - The request encapsulating the query and document identifier to compute a score explanation for

explain

public void explain(ExplainRequest request,
                    ActionListener<ExplainResponse> listener)
Description copied from interface: Client
Computes a score explanation for the specified request.

Specified by:
explain in interface Client
Overrides:
explain in class AbstractClient
Parameters:
request - The request encapsulating the query and document identifier to compute a score explanation for
listener - A listener to be notified of the result


Copyright © 2009-2012. All Rights Reserved.