Class: ElasticModel

Core ElasticModel

ElasticModel

new ElasticModel()

modules/core/elasticsearch.js, line 10
This model ist the central functionality to send and receive requests from elastic indices. It is called by several other tools such as the gdi search or the elastic search.

Extends

Methods

abortXhrRequestByServiceId(xhrRequests, serviceId){Object}

modules/core/elasticsearch.js, line 57
Aborts the running request by given serviceId and deletes it from the object.
Name Type Description
xhrRequests Object all xhr requests that are currently running.
serviceId String Id of rest-service.
Returns:
All xhr requests that have not be cancelled.

findAttributeByPath(object, path){*}

modules/core/elasticsearch.js, line 146
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.

parseResponse(event, responseEntryPath, result){Object}

modules/core/elasticsearch.js, line 118
Parses the response event.
Name Type Description
event Event Event of xhrRequest.
responseEntryPath String The path of the hits in the response JSON. The different levels of the response JSON are marked with "."
result Object Result object.
Name Type Description
status String Status of request "success" or "error".
message String Message of request.
hits Array.<Object> Array of result hits.
Returns:
Parsed result of request.
modules/core/elasticsearch.js, line 24
Main function to start the search using the xhrConfig.
Name Type Description
xhrConfig Object The configuration of the xhr request.
Name Type Default Description
serviceId String Id of the rest-service to be used. If serviceId is give, the url from the rest-service is taken.
url String If no serviceId is given, alternatively an url can be passed.
type String Type of request. "POST" or "GET".
payload Object Payload used to "POST" to url or be appended to url if type is "GET".
async Boolean Flag if request should be sent asynchronously.
responseEntryPath String "" The path of the hits in the response JSON. The different levels of the response JSON are marked with "."
Returns:
The result object of the request.

setXhrRequests(value){void}

modules/core/elasticsearch.js, line 170
Setter for attribute "xhrRequests"
Name Type Description
value Object xhr requests.

xhrSend(serviceId, url, xhrConfig, result){Object}

modules/core/elasticsearch.js, line 77
Sends the request
Name Type Description
serviceId String Id of rest-service.
url String url to send request.
xhrConfig Object Config with all necccessary params for request.
result Object Result object.
Name Type Description
status String Status of request "success" or "error".
message String Message of request.
hits Array.<Object> Array of result hits.
Returns:
Parsed result of request.