elastic-builder
elastic-builder copied to clipboard
termsQuery throws error when checking type of terms in REPL
node version: v8.11.3 esb version: 2.2.2
When using the termsQuery it incorrectly checks the terms type.
In the REPL:
esb.termsQuery('user', ['kimchy', 'elasticsearch'])
[ 'kimchy', 'elasticsearch' ] is of the type object
TypeError: Argument must be an instance of Array
at checkType (/home/austin/Workspace/node_modules/elastic-builder/lib/core/util.js:34:15)
at TermsQuery.values (/home/austin/Workspace/node_modules/elastic-builder/lib/queries/term-level-queries/terms-query.js:135:13)
at new TermsQuery (/home/austin/Workspace/node_modules/elastic-builder/lib/queries/term-level-queries/terms-query.js:75:46)
at Object.termsQuery (/home/austin/Workspace/node_modules/elastic-builder/lib/core/util.js:52:16)
@austince Thanks for reporting this. I have verified that this is an issue which only affects the REPL. The module works correctly when you require it inside node REPL:
elastic-builder on master [!] is 📦 v0.0.0-development
➜ node
> const esb = require('.')
undefined
> esb.termsQuery('user', ['kimchy', 'elasticsearch'])
TermsQuery {
queryType: 'terms',
_body: { terms: {} },
_queryOpts: {},
_isTermsLookup: false,
_termsLookupOpts: {},
_values: [ 'kimchy', 'elasticsearch' ],
_field: 'user' }
>
I will check and correct this soon.
Thanks @sudo-suhas! Yes, just using the node REPL is not a huge problem.