Class SearchRequestBuilder
- java.lang.Object
-
- uk.ac.bristol.hiddenmuseum.requests.SearchRequestBuilder
-
- All Implemented Interfaces:
RequestBuilder<SearchResponse>
public class SearchRequestBuilder extends java.lang.Object implements RequestBuilder<SearchResponse>
Creates requests to search the database
-
-
Constructor Summary
Constructors Constructor Description SearchRequestBuilder(java.lang.String base, java.lang.String dataset)
Create a search request builder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SearchRequestBuilder
exclude(java.lang.String field, java.lang.String value)
Sets a value to filter results by, excluding matches
Sets the `exclude.{field}` parameter when sending a request to the APIjava.lang.String
getUrl()
Returns the URL that will be queried by the requestSearchRequestBuilder
refineBy(java.lang.String field, java.lang.String value)
Sets a value to filter by, only including matches
Sets the `refine.{field}` parameter when sending a request to the APISearchResponse
sendRequest()
Send the completed request to the API, returns the responseSearchRequestBuilder
setLimit(int n)
Sets the maximum number of search results to show
Sets the `row` parameter when sending a request to the APISearchRequestBuilder
setOffset(int n)
Sets how many results to skip (e.g.SearchRequestBuilder
setQuery(java.lang.String query)
Set the long query string
Sets the `q` parameter when sending a request to the API
-
-
-
Method Detail
-
setQuery
public SearchRequestBuilder setQuery(java.lang.String query)
Set the long query string
Sets the `q` parameter when sending a request to the API- Parameters:
query
- long query string- Returns:
- this object, for chaining
-
setLimit
public SearchRequestBuilder setLimit(int n)
Sets the maximum number of search results to show
Sets the `row` parameter when sending a request to the API- Parameters:
n
- maximum number of search results to show- Returns:
- this object, for chaining
-
setOffset
public SearchRequestBuilder setOffset(int n)
Sets how many results to skip (e.g. for pagination)
Sets the `start` parameter when sending a request to the API- Parameters:
n
- how many to results to offset by- Returns:
- this object, for chaining
-
refineBy
public SearchRequestBuilder refineBy(java.lang.String field, java.lang.String value)
Sets a value to filter by, only including matches
Sets the `refine.{field}` parameter when sending a request to the API- Parameters:
field
- field to filter byvalue
- value to match- Returns:
- this object, for chaining
-
exclude
public SearchRequestBuilder exclude(java.lang.String field, java.lang.String value)
Sets a value to filter results by, excluding matches
Sets the `exclude.{field}` parameter when sending a request to the API- Parameters:
field
- field to filter byvalue
- value to match- Returns:
- this object, for chaining
-
getUrl
public java.lang.String getUrl()
Description copied from interface:RequestBuilder
Returns the URL that will be queried by the request- Specified by:
getUrl
in interfaceRequestBuilder<SearchResponse>
- Returns:
- URL
-
sendRequest
public SearchResponse sendRequest()
Description copied from interface:RequestBuilder
Send the completed request to the API, returns the response- Specified by:
sendRequest
in interfaceRequestBuilder<SearchResponse>
- Returns:
- appropriate Java object for this request
-
-