loopbackio / loopback-connector-elastic-search

Strongloop Loopback connector for Elasticsearch
MIT License
78 stars 56 forks source link

Docs say apiVersion is optional, but it is required to connect #51

Closed diekeure closed 7 years ago

diekeure commented 7 years ago

When you leave out the api-version, you get a type-error

TypeError: Cannot create data source "elasticsearch": Cannot initialize connector "es": Cannot read property 'indexOf' of undefined at ESConnector.connect (/diekeure/platformso/API/node_modules/loopback-connector-es/lib/esConnector.js:105:37) at Object.module.exports.initialize (/diekeure/platformso/API/node_modules/loopback-connector-es/lib/esConnector.js:30:30) at DataSource.setup (/diekeure/platformso/API/node_modules/loopback-datasource-juggler/lib/datasource.js:339:19) at new DataSource (/diekeure/platformso/API/node_modules/loopback-datasource-juggler/lib/datasource.js:117:8) at Registry.createDataSource (/diekeure/platformso/API/node_modules/loopback/lib/registry.js:355:12) at dataSourcesFromConfig (/diekeure/platformso/API/node_modules/loopback/lib/application.js:440:19) at EventEmitter.app.dataSource (/diekeure/platformso/API/node_modules/loopback/lib/application.js:235:14) at /diekeure/platformso/API/node_modules/loopback-boot/lib/executor.js:190:9 at /diekeure/platformso/API/node_modules/loopback-boot/lib/executor.js:281:5 at Array.forEach (native) at forEachKeyedObject (/diekeure/platformso/API/node_modules/loopback-boot/lib/executor.js:280:20) at setupDataSources (/diekeure/platformso/API/node_modules/loopback-boot/lib/executor.js:180:3) at execute (/diekeure/platformso/API/node_modules/loopback-boot/lib/executor.js:38:3) at bootLoopBackApp (/diekeure/platformso/API/node_modules/loopback-boot/index.js:154:3) at Object. (/diekeure/platformso/API/server/server.js:28:1) at Module._compile (module.js:556:32)

diekeure commented 7 years ago

Tested with version 1.0.7

pulkitsinghal commented 7 years ago

Yes correct, we added support for deleteByQuery for es v2.x and the code needs to decide how to operate for v1 versus v2 and for that we look at the apiVersion field ... will think about it more and either fix the docs or the code.

As a workaround, please continue to specify the apiVersion and thank you for reporting this.

pulkitsinghal commented 7 years ago

Overtime the default_api_branch": "2.3" and apiVersion will continue to be a moving target.

Since we don't have quick access to that property in the code when we need to make decisions based on version, for example: if (self.settings.apiVersion.indexOf('2') === 0) { ... lets just make apiVersion required in the docs.

pulkitsinghal commented 7 years ago

v1.0.8 has been released with a documentation update. Thank you for reporting the problem @diekeure