Constructor
new Elasticsearch(connectionObject, configs)
- Description:
- Constructor
- Source:
Parameters:
Name | Type | Description |
---|---|---|
connectionObject |
Object | |
configs |
Map |
Extends
- Database
Methods
(async, static) getDocCount(client, queryObject, indexAbsentErropt) → {Promise.<{count:number, indexAbsent:boolean}>}
- Description:
- returns Elasticsearch doc count result
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
const elastic = new mdx.Utils.Elasticsearch({node: "elasticsearch-url"},databaseConfigMap);
let result = mdx.Utils.Elasticsearch.getDocCount(elastic.getClient(),queryObject,false);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
client |
Object | |||
queryObject |
Object | queryObject | ||
indexAbsentErr |
boolean |
<optional> |
true
|
Throw an error when index doesn't exist |
Returns:
Elasticsearch result object
- Type
- Promise.<{count:number, indexAbsent:boolean}>
(static) getElasticErrors() → {Object}
- Description:
- return elasticsearch errors
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let elasticErrors = mdx.Utils.Elasticsearch.getElasticErrors();
Returns:
Elasticsearch error is returned
- Type
- Object
(static) getIndex(indexType) → {string|undefined}
- Description:
- Used to return index
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let indexType = "behavior";
let index = mdx.Utils.Elasticsearch.getIndex(indexType);
Parameters:
Name | Type | Description |
---|---|---|
indexType |
string |
Returns:
Returns index
- Type
- string | undefined
(async, static) getSearchResults(client, queryObject, indexAbsentErropt) → {Promise.<{body: ?Object, indexAbsent:boolean}>}
- Description:
- returns Elasticsearch query result
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
const elastic = new mdx.Utils.Elasticsearch({node: "elasticsearch-url"},databaseConfigMap);
let result = await mdx.Utils.Elasticsearch.getSearchResults(elastic.getClient(),queryObject,false);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
client |
Object | |||
queryObject |
Object | queryObject | ||
indexAbsentErr |
boolean |
<optional> |
true
|
Throw an error when index doesn't exist |
Returns:
Elasticsearch result object
- Type
- Promise.<{body: ?Object, indexAbsent:boolean}>
(async, static) initTimestampIngestPipeline(client, targetTimestampField) → {Promise.<{success:boolean}>}
- Description:
- Initializes Elasticsearch ingest pipeline related to insert timestamp
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
const elastic = new mdx.Utils.Elasticsearch({node: "elasticsearch-url"},databaseConfigMap);
let result = await mdx.Utils.Elasticsearch.initTimestampIngestPipeline(elastic.getClient(),"timestamp");
Parameters:
Name | Type | Description |
---|---|---|
client |
Object | |
targetTimestampField |
string |
Returns:
Returns success message if initialization is successful.
- Type
- Promise.<{success:boolean}>
(static) searchResultFormatter(esResult) → {Array.<Object>}
- Description:
- Used to format elasticsearch result object
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let resultList = mdx.Utils.Elasticsearch.searchResultFormatter(esResult);
Parameters:
Name | Type | Description |
---|---|---|
esResult |
Object | Elasticsearch Result Object |
Returns:
Array of documents obtained by searching Elasticsearch
- Type
- Array.<Object>