Options
All
  • Public
  • Public/Protected
  • All
Menu

Wrapper for the SmartSearch prepared search API. Main class and entrypoint for this library.

Hierarchy

  • SmartSearch

Index

Constructors

constructor

  • Parameters

    • host: string

      The hostname including protocol (eg.: https://my.smartsearch.backend).

    • preparedSearch: string

      The name of the prepared search to address.

    • Optional options: SmartSearchOptions

      The additional options to override the default parameters of the API endpoint, the render function and autocomplete function.

    Returns SmartSearch

Properties

Optional apiEndpoint

apiEndpoint: undefined | string

The API endpoint to which auto-complete and search queries are sent. As default the API_ENDPOINT is used.

host

host: string

The hostname including protocol (eg.: https://my.smartsearch.backend).

Optional options

The additional options to override the default parameters of the API endpoint, the render function and autocomplete function.

preparedSearch

preparedSearch: string

The name of the prepared search to address.

Accessors

autocompleteWidget

searchClient

Methods

attachAutocompleteWidget

  • attachAutocompleteWidget(inputElement: HTMLInputElement, renderTarget?: HTMLDivElement): void
  • This function attaches an autocomplete widget to the given input element. The css styling classes are:

    .smart-search-autocomplete-widget will be attached to the div-container displaying the list of autocomplete suggestions.
    .smart-search-autocomplete-active will be attached to the cursor for the actively selected autocomplete widget .
    .smart-search-autocomplete-item will be attached to a single autocomplete suggestion.
    #inputElement.id autocomplete-widget will be attached to the autocomplete-list.

    Parameters

    • inputElement: HTMLInputElement

      The input element to attach this widget to

    • Optional renderTarget: HTMLDivElement

      Optional. A div to attach the autocomplete widget to. If this parameter is left empty, the widget will be attached to the parent of the input element.

    Returns void

deleteCustomParams

  • deleteCustomParams(...keys: string[]): void
  • Deletes all parameters with keys matching the list of keys passed in

    Parameters

    • Rest ...keys: string[]

      one or more keys to be deleted

    Returns void

fetchAutocompleteList

  • Fetches the autocomplete suggestions matching the given prefix from the backend. The resulting array always has the length 5 and is sorted by relevance.

    Parameters

    Returns Promise<string[]>

getPageRenderer

  • Returns a page renderer object that provides functions to render pagination and search results

    Parameters

    • page: Page

      the page to berendered

    Returns PageRenderer

search

  • search(queryTerm: string, ...customParams: URLParam[]): Promise<Page>
  • Sends a search request with the given query term.

    Parameters

    • queryTerm: string

      The search term to use in the api request.

    • Rest ...customParams: URLParam[]

      One time use only parameters to append to this request

    Returns Promise<Page>

    The Page containing all the search results for that page.

searchWithGroup

  • searchWithGroup(queryTerm: string, groupField: string, groupLimit: number, ...customParams: URLParam[]): Promise<Map<string, Page>>
  • Sends a search request with the query term and the grouping options. For the method to work, the following groovy script must be added to the prepared search.

    
    def grouping = "off"
    grouping = parameter.get("grouping")?.get(0)
    def groupField = parameter.get("groupField")?.get(0)
    def groupLimit = parameter.get("groupLimit")?.get(0)
    
    if (grouping?.equals("on")) {
        solrQuery.set("group", true)
        solrQuery.set("group.field", groupField)
        solrQuery.set("group.limit", groupLimit)
    }
    

    Parameters

    • queryTerm: string

      The search term to use in the api request.

    • groupField: string

      The name of the field by which to group results.

    • groupLimit: number

      The number of results to return for each group. 1 is default, -1 returns all results for each group.

    • Rest ...customParams: URLParam[]

    Returns Promise<Map<string, Page>>

    A map consisting of the group value and the corresponding Page that contains the search results.

setCustomParams

  • setCustomParams(...customParams: URLParam[]): void
  • Sets custom parameters to be used in all requests to the SmartSearch backend. The same key may occur multiple times. If you call this function a second time you will overwrite all previously set parameters regardless of whether the keys are the same or not.

    Parameters

    • Rest ...customParams: URLParam[]

      one or multiple objects of type URLParam

    Returns void

Static version

  • version(): string
  • Returns string

Generated using TypeDoc