public abstract class AbstractBridge<RQ extends AbstractRequest<RQ>,Q extends AbstractQuery<RQ,Q>,D extends AbstractRecord<D>,R extends AbstractResults<D,R>>
extends java.lang.Object
The Bridge is the class responsible for marshalling a query to and from the search service.
Because the bridge holds a connection pool that is expensive to create, it is highly recommended
that the bridge is held in the application memory scope and reused where appropriate.
Do not create a new bridge object for each request as you will incur unnecessary overhead.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
clientKey |
static java.lang.String |
CLUSTER |
protected static java.lang.String |
COLON |
protected static java.lang.String |
HTTP |
protected static java.lang.String |
HTTPS |
| Constructor and Description |
|---|
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl)
Constructor to create a bridge object that connects to the search api. |
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
boolean compressResponse)
Constructor to create a bridge object that connects to the search api. |
| Modifier and Type | Method and Description |
|---|---|
protected java.io.InputStream |
fireRequest(java.lang.String url,
java.lang.String body,
boolean returnBinary) |
java.lang.String |
getBridgeRefinementsUrl() |
java.lang.String |
getBridgeUrl() |
java.lang.String |
getClusterBridgeUrl() |
protected abstract R |
map(java.io.InputStream data,
boolean returnBinary) |
protected abstract RefinementsResult |
mapRefinements(java.io.InputStream data,
boolean returnBinary) |
protected RefinementsResult |
refinements(Q query,
java.lang.String navigationName) |
R |
search(Q query)
Connects to the search service, parses the response into a model
|
void |
setRetryTimeout(long retryTimeout)
Sets the retry timeout for a failed request. |
void |
shutdown()
Cleanup HTTP connection pool. |
public static final java.lang.String CLUSTER
protected static final java.lang.String COLON
protected static final java.lang.String HTTP
protected static final java.lang.String HTTPS
protected java.lang.String clientKey
public AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl)
Constructor to create a bridge object that connects to the search api.
JSON Reference:
The key as found in your key management page in the command center
{"clientKey": ""}
clientKey - The key as found in your key management page in the command
center.baseUrl - The base url the bridge is serving on.public AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
boolean compressResponse)
Constructor to create a bridge object that connects to the search api.
JSON Reference:
The key as found in your key management page in the command center
{"clientKey": ""}
clientKey - The key as found in your key management page in the command
center.baseUrl - The base url the bridge is serving on.compressResponse - true to compress the response content, false to send uncompressed response.public java.lang.String getBridgeUrl()
public java.lang.String getBridgeRefinementsUrl()
public java.lang.String getClusterBridgeUrl()
protected abstract R map(java.io.InputStream data, boolean returnBinary)
protected abstract RefinementsResult mapRefinements(java.io.InputStream data, boolean returnBinary)
public R search(Q query) throws java.io.IOException
Connects to the search service, parses the response into a model
query - A query representing the search.java.io.IOExceptionprotected RefinementsResult refinements(Q query, java.lang.String navigationName) throws java.io.IOException
java.io.IOExceptionprotected java.io.InputStream fireRequest(java.lang.String url,
java.lang.String body,
boolean returnBinary)
throws java.io.IOException
java.io.IOExceptionpublic void shutdown()
Cleanup HTTP connection pool.
public void setRetryTimeout(long retryTimeout)
Sets the retry timeout for a failed request.
retryTimeout - Copyright © 2013–2015 GroupBy Inc.. All rights reserved.