Class: ElasticSearchModel

Searchbar.ElasticSearch ElasticSearchModel

ElasticSearchModel

new ElasticSearchModel()

modules/searchbar/elasticSearch/model.js, line 52
Properties:
Name Type Default Description
minChars Number 3 Minimum length of search string to start.
serviceId String "11" Id of restService to derive url from.
url String "" Url derived from restService.
payload Object {} Payload used to POST to url.
searchStringAttribute String "searchString" The Search string is added to the payload object with this key.
type String "POST" The type of the request. "POST" or "GET".
responseEntryPath String "" The path of the hits in the response JSON. The different levels of the response JSON are marked with "."
triggerEvent Object = {} An object defining the channel and event to be posted by clicking on the search result.
Properties
Name Type Description
channel String = "" Channel of radio event.
event String = "" Event of radio event.
hitMap Object = {name: "", id: "id", coordinate: "coordinate"} Mapping object of the response hit to fit the structure of the searchbars hits.
hitType String = "Elastic" Type of the hit to be appended in the recommended list.
hitGlyphicon String = "glyphicon-road" Css class of the glyphicon to be prepended in the recommended list.
async Boolean = false Flag if request should be asynchronous.
useProxy Boolean = false Flag if request should be proxied.
elasticSearch ElasticModel = new ElasticSearch() ElasticModel.
Fires:
Listens to Events:

Extends

Methods

appendSearchStringToPayload(payload, searchStringAttribute, searchString){Object}

modules/searchbar/elasticSearch/model.js, line 95
Recursively searches for the searchStringAttribute key and sets the searchString. Adds the search string to the payload using the given key
Name Type Description
payload Object Payload as Object
searchStringAttribute String Attribute key to be added to the payload object.
searchString String Search string to be added using the searchStringAttribute.
Returns:
the payload with the search string.

createHit(result, hitMap, hitType, hitGlyphicon, triggerEvent){Object}

modules/searchbar/elasticSearch/model.js, line 144
Creates hit that is sent to the hitList.
Name Type Description
result Object Result object from elastcisearch request.
hitMap Object Mapping object. Used to map results attributes to neccessary hit attributes.
hitType String Type of hit.
hitGlyphicon String Glyphicon class to show in reccomendedList
triggerEvent Object Object defining channel and event. used to fire event on mouseover and click in recommendedList.
Returns:
hit.

createRecommendedList(responseData){void}

modules/searchbar/elasticSearch/model.js, line 116
Creates the recommended List
Name Type Description
responseData Array.<Object> Response data.
Fires:

findAttributeByPath(object, path){*}

modules/searchbar/elasticSearch/model.js, line 166
Returns the attribute value of the given object by path. If path is an array, the function recursively iterates over the object for each part and pushes the value in an array. Otherwise only the value of the given attribute path will be returned.
Name Type Description
object Object Object to derive value from.
path String | Array.<String> Path of the attribute. "." in the path indicates the next deeper level.
Returns:
Value that is at position of given path.
modules/searchbar/elasticSearch/model.js, line 68
Checks if the minChars criterium is passed, then sends the request to the elastic search index.
Name Type Description
searchString String The search string.