public abstract class AbstractQuery<R extends AbstractRequest<R>,Q extends AbstractQuery<R,Q>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected RestrictNavigation |
restrictNavigation |
static java.lang.String |
TILDE_REGEX |
| Constructor and Description |
|---|
AbstractQuery()
Default constructor
|
| Modifier and Type | Method and Description |
|---|---|
Q |
addCustomUrlParam(CustomUrlParam customUrlParam)
Sets any additional parameters that can be used to trigger rules. |
Q |
addCustomUrlParam(java.lang.String key,
java.lang.String value)
Sets any additional parameters that can be used to trigger rules. |
Q |
addCustomUrlParamsByString(java.lang.String values)
Helper method that takes a ~ separated string of additional parameters that can be
used to trigger rules. |
Q |
addFields(java.lang.String... name)
Specify which fields should be returned on each record that comes back from the engine. |
Q |
addOrField(java.lang.String... name)
Specify which fields should be queried with 'OR' instead of the default 'AND'. |
Q |
addRangeRefinement(java.lang.String navigationName,
java.lang.String low,
java.lang.String high)
Add a range refinement. |
Q |
addRangeRefinement(java.lang.String navigationName,
java.lang.String low,
java.lang.String high,
boolean exclude)
Add a range refinement. |
Q |
addRefinementsByString(java.lang.String refinementString)
A helper method to parse and set refinements. |
Q |
addValueRefinement(java.lang.String navigationName,
java.lang.String value)
Add a value refinement. |
Q |
addValueRefinement(java.lang.String navigationName,
java.lang.String value,
boolean exclude)
Add a value refinement. |
protected static Sort |
convertSort(Sort sort) |
protected abstract R |
generateRequest() |
java.lang.String |
getArea() |
java.lang.String |
getBiasingProfile() |
java.lang.String |
getBridgeJson(java.lang.String clientKey)
Used internally by the bridge object to generate the JSON that is sent to the search service. |
protected java.lang.String |
getBridgeJsonRefinementSearch(java.lang.String clientKey) |
java.lang.String |
getBridgeRefinementsJson(java.lang.String clientKey,
java.lang.String navigationName)
Used internally by the bridge object to generate the JSON that is sent to the search service. |
java.lang.String |
getCollection() |
java.util.List<CustomUrlParam> |
getCustomUrlParams() |
java.lang.String |
getCustomUrlParamsString() |
java.util.List<java.lang.String> |
getFields() |
java.lang.String |
getLanguage() |
java.util.Map<java.lang.String,Navigation> |
getNavigations() |
java.util.List<java.lang.String> |
getOrFields() |
long |
getPageSize() |
java.lang.String |
getQuery() |
java.lang.String |
getRefinementString() |
long |
getSkip() |
java.lang.String |
getSubCollection()
Deprecated.
since 2.0, use getCollection instead.
|
boolean |
isAutocorrectionDisabled() |
boolean |
isPruneRefinements() |
boolean |
isReturnBinary() |
protected abstract RefinementsRequest<R> |
populateRefinementRequest() |
Q |
setArea(java.lang.String area)
The area you wish to fire against, production, staging, etc... |
Q |
setBiasingProfile(java.lang.String biasingProfile)
Override the biasing profile used for this query - takes precedence over any
biasing profile set in the command center. |
Q |
setCollection(java.lang.String collection)
The collection to use. |
Q |
setDisableAutocorrection(boolean disableAutocorrection)
Specifies whether the auto-correction behavior should be disabled. |
Q |
setLanguage(java.lang.String language)
Sets the language filter on the query and restricts the results to a certain language. |
Q |
setPageSize(int pageSize)
Page size. |
Q |
setPruneRefinements(boolean pruneRefinements)
Specifies whether refinements should be pruned from
the available navigation. |
Q |
setQuery(java.lang.String query)
Set a search string. |
Q |
setRestrictNavigation(RestrictNavigation restrictNavigation)
Warning This will count as two queries against your search index. |
Q |
setRestrictNavigation(java.lang.String name,
int count)
Warning This will count as two queries against your search index. |
Q |
setReturnBinary(boolean returnBinary)
Tells the search service to return binary data. |
Q |
setSkip(int skip)
Tell the search service to offset to the Nth record. |
Q |
setSubCollection(java.lang.String subCollection)
Deprecated.
since 2.0, use setCollection instead.
|
protected java.lang.String[] |
splitRefinements(java.lang.String refinementString) |
public static final java.lang.String TILDE_REGEX
protected RestrictNavigation restrictNavigation
protected abstract R generateRequest()
protected abstract RefinementsRequest<R> populateRefinementRequest()
public java.lang.String getBridgeJson(java.lang.String clientKey)
Used internally by the bridge object to generate the JSON that is sent to the search service.
clientKey - The client key used to authenticate this request.public java.lang.String getBridgeRefinementsJson(java.lang.String clientKey,
java.lang.String navigationName)
Used internally by the bridge object to generate the JSON that is sent to the search service.
clientKey - The client key used to authenticate this request.public java.lang.String getQuery()
public Q setQuery(java.lang.String query)
Set a search string. If query is blank all records are considered.
JSON Reference:
{ "query": "gloves" }
query - The search term to fire against the enginepublic java.lang.String getSubCollection()
public Q setSubCollection(java.lang.String subCollection)
subCollection - The string representation of a collection query.public java.lang.String getCollection()
public Q setCollection(java.lang.String collection)
The collection to use. If you have uploaded additional data into collections apart from the default
collection using the stream tool, you can access them by specifying them here.
You can also search across multiple collections. It is important to note that relevancy is affected across
collections and it is recommended that collections be modeled so that cross-collection searching is not required.
As an example, to search across FAQs and Manuals you would use "FAQs|Manuals".
JSON Reference:
{ "collection": "FAQs" }
{ "collection": "FAQs|Manuals" }
collection - The string representation of a collection query.public java.lang.String getArea()
public Q setArea(java.lang.String area)
The area you wish to fire against, production, staging, etc...
If blank, the default production area will be used.
JSON Reference:
{ "area": "Development" }
area - The area name.public java.lang.String getRefinementString()
public java.lang.String getCustomUrlParamsString()
public java.util.List<CustomUrlParam> getCustomUrlParams()
protected java.lang.String getBridgeJsonRefinementSearch(java.lang.String clientKey)
clientKey - Your client keyprotected java.lang.String[] splitRefinements(java.lang.String refinementString)
public Q addRefinementsByString(java.lang.String refinementString)
A helper method to parse and set refinements.
If you pass in refinements of the format
Brand=Bose~price:20..80
The query object will correctly parse out the refinements.
refinementString - A tilde separated list of refinementspublic Q addCustomUrlParam(CustomUrlParam customUrlParam)
Sets any additional parameters that can be used to trigger rules.
Takes a CustomUrlParam object.
customUrlParam - The parameter to addpublic Q addCustomUrlParam(java.lang.String key, java.lang.String value)
Sets any additional parameters that can be used to trigger rules.
Takes a name and a value.
JSON Reference:
Custom URL parameters separated by ~ in the form:
{ "customUrlParams": [ { "key": "region", "value": "east" } ] }
key - The parameter keyvalue - The parameter valuepublic Q addCustomUrlParamsByString(java.lang.String values)
Helper method that takes a ~ separated string of additional parameters that can be
used to trigger rules. Takes ~ separated name/value list
values - The list of name/valuespublic java.util.List<java.lang.String> getFields()
public Q addFields(java.lang.String... name)
Specify which fields should be returned on each record that comes back from the engine. You may specify more
than one field, if you specify * all fields will be returned.
If this parameter is blank the search service will return no attributes with the records.
JSON Reference:
{ "fields": [ "width", "brand", "height" ] }
name - The case-sensitive name of the attribute to returnpublic java.util.List<java.lang.String> getOrFields()
public Q addOrField(java.lang.String... name)
Specify which fields should be queried with 'OR' instead of the default 'AND'.
This behavior is typically defined in command center on a per navigation basis. However,
you can set which fields should be treated as an OR field at the query level if desired.
As with normal refinement selections, once you have refined, the list of refinements for
that selected navigation will no longer be returned.
JSON Reference:
{ "orFields": [ "field1", "field2" ] }
name - The field that should be treated as OR by the search service before
being executed.public Q addRangeRefinement(java.lang.String navigationName, java.lang.String low, java.lang.String high)
Add a range refinement. Takes a refinement name, a lower and upper bounds.
navigationName - The name of the refinementlow - The low valuehigh - The high valuepublic Q addRangeRefinement(java.lang.String navigationName, java.lang.String low, java.lang.String high, boolean exclude)
Add a range refinement. Takes a refinement name, a lower and upper bounds, and whether or not to exclude
this refinement.
navigationName - The name of the refinementlow - The low valuehigh - The high valueexclude - True if the results should exclude this range refinement, false otherwisepublic Q addValueRefinement(java.lang.String navigationName, java.lang.String value)
Add a value refinement. Takes a refinement name and a value.
navigationName - The name of the navigationvalue - The refinement valuepublic Q addValueRefinement(java.lang.String navigationName, java.lang.String value, boolean exclude)
Add a value refinement. Takes a refinement name, a value, and whether or not to exclude this refinement.
navigationName - The name of the navigationvalue - The refinement valueexclude - True if the results should exclude this value refinement, false otherwisepublic long getSkip()
public Q setSkip(int skip)
Tell the search service to offset to the Nth record.
JSON Reference:
{ "skip": 400 }
skip - The number of documents to skippublic long getPageSize()
public Q setPageSize(int pageSize)
Page size. Default is 10.
JSON Reference:
{ "pageSize": 8 }
pageSize - The number of records to return with the query.public java.util.Map<java.lang.String,Navigation> getNavigations()
public boolean isReturnBinary()
public Q setReturnBinary(boolean returnBinary)
Tells the search service to return binary data. This is enabled by default in the APIs for more efficient transport.
To disable this in an API, set this to `false`.
JSON Reference:
If passed true, informs the search service to return binary data rather than JSON.
{ "returnBinary": true }
returnBinary - Whether to tell the search service to return binary data rather than JSON.public java.lang.String getBiasingProfile()
public Q setBiasingProfile(java.lang.String biasingProfile)
Override the biasing profile used for this query - takes precedence over any
biasing profile set in the command center.
JSON Reference:
{ "biasingProfile": "PopularityBias" }
biasingProfile - public java.lang.String getLanguage()
public Q setLanguage(java.lang.String language)
Sets the language filter on the query and restricts the results to a certain language. If you do not specify a
language, english ("lang_en") will be considered the default. An unrecognized language will result in an error.
Currently supported languages are:
lang_en
JSON Reference:
{ "language": "lang_en" }
language - The value for language restrictpublic boolean isPruneRefinements()
public Q setPruneRefinements(boolean pruneRefinements)
Specifies whether refinements should be pruned from
the available navigation.
A refinement is pruned if the number of results for that refinement is zero.
If all refinements from a navigation are pruned, that
navigation is also pruned.
Defaults to true
JSON Reference:
{ pruneRefinements: false }
pruneRefinements - public boolean isAutocorrectionDisabled()
public Q setDisableAutocorrection(boolean disableAutocorrection)
Specifies whether the auto-correction behavior should be disabled. By default, when no results are returned
for the given query (and there is a did-you-mean available), the first did-you-mean is automatically queried
instead.
Defaults to false
JSON Reference:
{ "disableAutocorrection": false }
disableAutocorrection - public Q setRestrictNavigation(RestrictNavigation restrictNavigation)
Warning This will count as two queries against your search index.
Typically, this feature is used when you have a large number of navigation items that will overwhelm the end
user. It works by using one of the existing navigation items to decide what the query is about and fires a second
query to restrict the navigation to the most relevant set of navigation items for this search term.
For example, if you pass in a search of `paper` and a restrict navigation of `category:2`
The bridge will find the category navigation refinements in the first query and fire a second query for the top 2
most populous categories. Therefore, a search for something generic like "paper" will bring back top category
matches like copy paper (1,030), paper pads (567). The bridge will fire off the second query with the search
term, plus an OR refinement with the most likely categories. The navigation items in the first query are
entirely replaced with the navigation items in the second query, except for the navigation that was used for the
restriction so that users still have the ability to navigate by all category types.
JSON Reference:
{ "restrictNavigation": { "name": "category", "count": 2 } }
restrictNavigation - Restriction criteriapublic Q setRestrictNavigation(java.lang.String name, int count)
Warning This will count as two queries against your search index.
Typically, this feature is used when you have a large number of navigation items that will overwhelm the end
user. It works by using one of the existing navigation items to decide what the query is about and fires a second
query to restrict the navigation to the most relevant set of navigation items for this search term.
For example, if you pass in a search of `paper` and a restrict navigation of `category:2`
The bridge will find the category navigation refinements in the first query and fire a second query for the top
2 most populous categories. Therefore, a search for something generic like "paper" will bring back top category
matches like copy paper (1,030), paper pads (567). The bridge will fire off the second query with the search
term, plus an OR refinement with the most likely categories. The navigation items in the first query are
entirely replaced with the navigation items in the second query, except for the navigation that was used
for the restriction so that users still have the ability to navigate by all category types.
name - the name of the field should be used in the navigation restriction in the second query.count - the number of fields matchesCopyright © 2013–2015 GroupBy Inc.. All rights reserved.