public abstract class AbstractBridge
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 overhead that will
bring down your UI servers when under heavy load!
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
clientKey |
static java.lang.String |
CLUSTER |
protected static java.lang.String |
COLON |
static int |
DEFAULT_MAX_TRIES |
static int |
DEFAULT_RETRY_TIMEOUT |
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. |
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
boolean compressResponse,
ConnectionConfiguration config)
Constructor to create a bridge object that connects to the search api. |
AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
ConnectionConfiguration config)
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.util.Map<java.lang.String,java.lang.String> urlParams,
java.lang.String body,
boolean returnBinary) |
protected java.net.URI |
generateURI(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params,
int tries) |
java.lang.String |
getBridgeRefinementsUrl() |
java.lang.String |
getBridgeUrl() |
java.lang.String |
getClusterBridgeUrl() |
java.util.List<com.groupbyinc.common.apache.http.Header> |
getHeaders() |
protected void |
handleErrorStatus(java.lang.String status,
byte[] bytes,
boolean returnBinary) |
protected Results |
map(java.io.InputStream data,
boolean returnBinary) |
protected RefinementsResult |
mapRefinements(java.io.InputStream data,
boolean returnBinary) |
RefinementsResult |
refinements(Query query,
java.lang.String navigationName)
Connects to the refinements service, parses the response into a model
Retrieves at most 10,000 refinements for the navigation specified. |
RefinementsResult |
refinements(RefinementsRequest request) |
Results |
search(Query query)
Connects to the search service, parses the response into a model
|
Results |
search(Request request) |
void |
setHeaders(java.util.List<com.groupbyinc.common.apache.http.Header> headers)
Set a list of headers. |
void |
setMaxTries(long maxTries)
Sets the maximum number of times to try a request before returning an error. |
void |
setRetryTimeout(long retryTimeout)
Sets the retry timeout for a failed request. |
void |
shutdown()
Cleanup HTTP connection pool. |
public static final int DEFAULT_RETRY_TIMEOUT
public static final int DEFAULT_MAX_TRIES
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,
ConnectionConfiguration config)
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.config - Configuration for the underlying HttpClient instance.public AbstractBridge(java.lang.String clientKey,
java.lang.String baseUrl,
ConnectionConfiguration config)
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.config - Configuration for the underlying HttpClient instance.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 getClusterBridgeUrl()
public Results search(Query 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 java.io.InputStream fireRequest(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> urlParams,
java.lang.String body,
boolean returnBinary)
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String getBridgeUrl()
protected Results map(java.io.InputStream data, boolean returnBinary)
protected void handleErrorStatus(java.lang.String status,
byte[] bytes,
boolean returnBinary)
throws java.io.IOException
java.io.IOExceptionprotected java.net.URI generateURI(java.lang.String url,
java.util.Map<java.lang.String,java.lang.String> params,
int tries)
throws java.net.URISyntaxException
java.net.URISyntaxExceptionpublic Results search(Request request) throws java.io.IOException
java.io.IOExceptionpublic RefinementsResult refinements(Query query, java.lang.String navigationName) throws java.io.IOException
Connects to the refinements service, parses the response into a model
Retrieves at most 10,000 refinements for the navigation specified.
query - A query representing the search.navigationName - The name of the navigation to get more refinements for.java.io.IOExceptionpublic java.lang.String getBridgeRefinementsUrl()
protected RefinementsResult mapRefinements(java.io.InputStream data, boolean returnBinary)
public RefinementsResult refinements(RefinementsRequest request) 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 - the retry timeoutpublic void setMaxTries(long maxTries)
Sets the maximum number of times to try a request before returning an error.
maxTries - the maximum number of request attemptspublic java.util.List<com.groupbyinc.common.apache.http.Header> getHeaders()
public void setHeaders(java.util.List<com.groupbyinc.common.apache.http.Header> headers)
Set a list of headers. Use `getHeaders().add(new BasicHeader())`
headers - Copyright © 2013–2016 GroupBy Inc.. All rights reserved.