Client per request question


(Neil) #1

Hi,

I'm using the java api and for searching I'd like to know whether I
can use the same client for every search request that comes through,
or do I need to create a new client for each request?

Namely, is the client thread safe for its given request?

Then how does this tie in with the OperationThreaded described here:

http://www.elasticsearch.org/guide/reference/java-api/search.html

NO_THREADS
SINGLE_THREAD
THREAD_PER_SHARD

I'm not seeing how to set these fields in the GetRequestBuilder.

Also, what does the realtime method do in the GetRequestBuilder?

Thanks,

Neil


(Shay Banon) #2

You should use the same client for all requests, its thread safe. The
operation threaded for search request controls how the search is executed on
a node, and usually not really relevant for remote clients.

The realtime flag for get request controls if "realtime" get will be used or
not (by default, realtime get is enabled, and you can get a document once
indexed regardless of the refresh interval of the index or if it was
refreshed or not).

On Mon, Oct 3, 2011 at 9:53 PM, Neil neilmatthewlott@gmail.com wrote:

Hi,

I'm using the java api and for searching I'd like to know whether I
can use the same client for every search request that comes through,
or do I need to create a new client for each request?

Namely, is the client thread safe for its given request?

Then how does this tie in with the OperationThreaded described here:

http://www.elasticsearch.org/guide/reference/java-api/search.html

NO_THREADS
SINGLE_THREAD
THREAD_PER_SHARD

I'm not seeing how to set these fields in the GetRequestBuilder.

Also, what does the realtime method do in the GetRequestBuilder?

Thanks,

Neil


(system) #3