diff --git a/doc/7/controllers/document/search/index.md b/doc/7/controllers/document/search/index.md
index 3609c7f11..7d294e7b4 100644
--- a/doc/7/controllers/document/search/index.md
+++ b/doc/7/controllers/document/search/index.md
@@ -16,6 +16,17 @@ That limit is by default set at 10000 documents, and you can't get over it even
When processing a large number of documents (i.e. more than 1000), it is advised to paginate the results using [SearchResult.next](/sdk/js/7/core-classes/search-result/next) rather than increasing the size parameter.
:::
+::: warning
+When using a cursor with the `scroll` option, Elasticsearch has to duplicate the transaction log to keep the same result during the entire scroll session.
+It can lead to memory leaks if a scroll duration too great is provided, or if too many scroll sessions are open simultaneously.
+:::
+
+::: info
+
+You can restrict the scroll session maximum duration under the `services.storage.maxScrollDuration` configuration key.
+:::
+
+
```js
diff --git a/doc/7/core-classes/search-result/next/index.md b/doc/7/core-classes/search-result/next/index.md
index 843ca788b..3233dccd7 100644
--- a/doc/7/core-classes/search-result/next/index.md
+++ b/doc/7/core-classes/search-result/next/index.md
@@ -40,6 +40,16 @@ For that reason, this method is guaranteed to return consistent results, even if
This is the most consistent way to paginate results, however, this comes at a higher computing cost for the server.
+::: warning
+When using a cursor with the `scroll` option, Elasticsearch has to duplicate the transaction log to keep the same result during the entire scroll session.
+It can lead to memory leaks if ascroll duration too great is provided, or if too many scroll sessions are open simultaneously.
+:::
+
+::: info
+
+You can restrict the scroll session maximum duration under the `services.storage.maxScrollDuration` configuration key.
+:::
+
<<< ./snippets/scroll.js
### Strategy: sort / size
diff --git a/index.js b/index.js
index 7261dcf80..fef5f889a 100644
--- a/index.js
+++ b/index.js
@@ -1,12 +1,16 @@
-const
- Kuzzle = require('./src/Kuzzle'),
- {
- Http,
- WebSocket
- } = require('./src/protocols'),
- BaseController = require('./src/controllers/base'),
- KuzzleAbstractProtocol = require('./src/protocols/abstract/common'),
- KuzzleEventEmitter = require('./src/eventEmitter');
+const Kuzzle = require('./src/Kuzzle');
+const { Http, WebSocket } = require('./src/protocols');
+const BaseController = require('./src/controllers/base');
+const KuzzleAbstractProtocol = require('./src/protocols/abstract/common');
+const KuzzleEventEmitter = require('./src/eventEmitter');
+const {
+ SearchResultBase,
+ DocumentSearchResult,
+ ProfileSearchResult,
+ RoleSearchResult,
+ SpecificationSearchResult,
+ UserSearchResult
+} = require('./src/controllers/searchResult');
if (typeof window !== 'undefined' && typeof BUILT === 'undefined') {
throw new Error('It looks like you are using the Nodejs version of Kuzzle SDK ' +
@@ -21,5 +25,11 @@ module.exports = {
WebSocket,
BaseController,
KuzzleAbstractProtocol,
- KuzzleEventEmitter
+ KuzzleEventEmitter,
+ SearchResultBase,
+ DocumentSearchResult,
+ ProfileSearchResult,
+ RoleSearchResult,
+ SpecificationSearchResult,
+ UserSearchResult
};
diff --git a/package-lock.json b/package-lock.json
index 1efaedd2b..67fb3b245 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
- "version": "7.1.1",
+ "version": "7.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -2594,7 +2594,7 @@
"@sinonjs/text-encoding": {
"version": "0.7.1",
"resolved": "https://registry.npmjs.org/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz",
- "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==",
+ "integrity": "sha1-jaXGUwkVZT86Hzj9XxAdjD+AecU=",
"dev": true
},
"@tootallnate/once": {
@@ -2863,7 +2863,7 @@
"ansi-colors": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz",
- "integrity": "sha512-LEHHyuhlPY3TmuUYMh2oz89lTShfvgbmzaBcxve9t/9Wuy7Dwf4yoAKcND7KFT1HAQfqZ12qtc+DUrBMeKF9nw==",
+ "integrity": "sha1-V9NbhoboUeLMBMQD8cACA5dqGBM=",
"dev": true
},
"ansi-escapes": {
@@ -3024,7 +3024,7 @@
"astral-regex": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-1.0.0.tgz",
- "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
+ "integrity": "sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k=",
"dev": true
},
"async-each": {
@@ -3139,7 +3139,7 @@
"big.js": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
- "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ=="
+ "integrity": "sha1-ZfCvOC9Xi83HQr2cKB6cstd2gyg="
},
"binary-extensions": {
"version": "1.13.1",
@@ -3242,7 +3242,7 @@
"browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
- "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
+ "integrity": "sha1-uqVZ7hTO1zRSIputcyZGfGH6vWA=",
"dev": true
},
"browserify-aes": {
@@ -3334,7 +3334,7 @@
"buffer-from": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
- "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
+ "integrity": "sha1-MnE7wCj3XAL9txDXx7zsHyxgcO8="
},
"buffer-xor": {
"version": "1.0.3",
@@ -3452,7 +3452,7 @@
"camelcase": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",
- "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",
+ "integrity": "sha1-48mzFWnhBoEd8kL3FXJaH0xJQyA=",
"dev": true
},
"caniuse-lite": {
@@ -3484,7 +3484,7 @@
"chardet": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz",
- "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==",
+ "integrity": "sha1-kAlISfCTfy7twkJdDSip5fDLrZ4=",
"dev": true
},
"chokidar": {
@@ -3581,12 +3581,12 @@
"cli-spinners": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.2.0.tgz",
- "integrity": "sha512-tgU3fKwzYjiLEQgPMD9Jt+JjHVL9kW93FiIMX/l7rivvOD4/LL0Mf7gda3+4U2KJBloybwgj5KEoQgGRioMiKQ=="
+ "integrity": "sha1-6LmI2SBsaSMC2O6DTnqFwBRNj3c="
},
"cli-table3": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz",
- "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==",
+ "integrity": "sha1-AlI3LZTfxA29jfBgBfSPMfZW8gI=",
"dev": true,
"requires": {
"colors": "^1.1.2",
@@ -3847,7 +3847,7 @@
"concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
- "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
+ "integrity": "sha1-kEvfGUzTEi/Gdcd/xKw9T/D9GjQ=",
"requires": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
@@ -4159,7 +4159,7 @@
"define-properties": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
- "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
+ "integrity": "sha1-z4jabL7ib+bbcJT2HYcMvYTO6fE=",
"requires": {
"object-keys": "^1.0.12"
}
@@ -4264,7 +4264,7 @@
"duration": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/duration/-/duration-0.2.2.tgz",
- "integrity": "sha512-06kgtea+bGreF5eKYgI/36A6pLXggY7oR4p1pq4SmdFBn1ReOL5D8RhG64VrqfTTKNucqqtBAwEj8aB88mcqrg==",
+ "integrity": "sha1-3fFJvDvGkBFQ/pAXER0BazNX9Sk=",
"dev": true,
"requires": {
"d": "1",
@@ -4405,7 +4405,7 @@
"es6-error": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz",
- "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
+ "integrity": "sha1-njr0B0Wd7tR+mpH5uIWoTrBcVh0=",
"dev": true
},
"es6-iterator": {
@@ -4671,7 +4671,7 @@
"eslint-scope": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz",
- "integrity": "sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg==",
+ "integrity": "sha1-ygODMxD2iJoyZHgaqC5j65z+eEg=",
"requires": {
"esrecurse": "^4.1.0",
"estraverse": "^4.1.1"
@@ -4728,7 +4728,7 @@
"esrecurse": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz",
- "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==",
+ "integrity": "sha1-AHo7n9vCs7uH5IeeoZyS/b05Qs8=",
"requires": {
"estraverse": "^4.1.0"
}
@@ -4909,7 +4909,7 @@
"external-editor": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz",
- "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==",
+ "integrity": "sha1-ywP3QL764D6k0oPK7SdBqD8zVJU=",
"dev": true,
"requires": {
"chardet": "^0.7.0",
@@ -5095,7 +5095,7 @@
"find-cache-dir": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz",
- "integrity": "sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ==",
+ "integrity": "sha1-jQ+UzRP+Q8bHwmGg2GEVypGMBfc=",
"requires": {
"commondir": "^1.0.1",
"make-dir": "^2.0.0",
@@ -5105,7 +5105,7 @@
"find-up": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz",
- "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==",
+ "integrity": "sha1-SRafHXmTQwZG2mHsxa41XCHJe3M=",
"requires": {
"locate-path": "^3.0.0"
}
@@ -5113,7 +5113,7 @@
"flat": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/flat/-/flat-4.1.0.tgz",
- "integrity": "sha512-Px/TiLIznH7gEDlPXcUD4KnBusa6kR6ayRUVcnEAbreRIuhkqow/mun59BuRXwoYk7ZQOLW1ZM05ilIvK38hFw==",
+ "integrity": "sha1-CQvsiwXjnLowl0fx1YjwTbr5jbI=",
"dev": true,
"requires": {
"is-buffer": "~2.0.3"
@@ -5152,7 +5152,7 @@
"flatted": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.1.tgz",
- "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==",
+ "integrity": "sha1-aeV8qo8OrLwoHS4stFjUb9tEngg=",
"dev": true
},
"flush-write-stream": {
@@ -5791,7 +5791,7 @@
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
- "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ "integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0="
},
"functional-red-black-tree": {
"version": "1.0.1",
@@ -5856,7 +5856,7 @@
"globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
- "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA=="
+ "integrity": "sha1-q4eVM4hooLq9hSV1gBjCp+uVxC4="
},
"graceful-fs": {
"version": "4.1.11",
@@ -5866,13 +5866,13 @@
"growl": {
"version": "1.10.5",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
- "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
+ "integrity": "sha1-8nNdwig2dPpnR4sQGBBZNVw2nl4=",
"dev": true
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
- "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "integrity": "sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y=",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
@@ -5970,7 +5970,7 @@
"he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
- "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
+ "integrity": "sha1-hK5l+n6vsWX922FWauFLrwVmTw8=",
"dev": true
},
"hmac-drbg": {
@@ -6066,7 +6066,7 @@
"ignore": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz",
- "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==",
+ "integrity": "sha1-dQ49tYYgh7RzfrrIIH/9HvJ7Jfw=",
"dev": true
},
"ignore-walk": {
@@ -6734,12 +6734,12 @@
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
- "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA=="
+ "integrity": "sha1-gFZNLkg9rPbo7yCWUKZ98/DCg6Q="
},
"json-parse-better-errors": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
- "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw=="
+ "integrity": "sha1-u4Z8+zRQ5pEHwTHRxRS6s9yLyqk="
},
"json-schema-traverse": {
"version": "0.4.1",
@@ -7091,7 +7091,7 @@
"locate-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz",
- "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==",
+ "integrity": "sha1-2+w7OrdZdYBxtY/ln8QYca8hQA4=",
"requires": {
"p-locate": "^3.0.0",
"path-exists": "^3.0.0"
@@ -7232,7 +7232,7 @@
"make-dir": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
- "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==",
+ "integrity": "sha1-XwMQ4YuL6JjMBwCSlaMK5B6R5vU=",
"requires": {
"pify": "^4.0.1",
"semver": "^5.6.0"
@@ -7655,7 +7655,7 @@
"mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
- "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==",
+ "integrity": "sha1-lQCAV6Vsr63CvGPd5/n/aVWUjjI=",
"dev": true,
"requires": {
"any-promise": "^1.0.0",
@@ -7706,11 +7706,11 @@
"neo-async": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz",
- "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw=="
+ "integrity": "sha1-rCetpmFn+ohJpq3dg39rGJrSCBw="
},
"next-tick": {
"version": "1.0.0",
- "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
+ "resolved": "http://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
"dev": true
},
@@ -7735,7 +7735,7 @@
"no-case": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/no-case/-/no-case-2.3.2.tgz",
- "integrity": "sha512-rmTZ9kz+f3rCvK2TD1Ue/oZlns7OGoIWP4fc3llxxRXlOkHKoWPPWJOfFYpITabSow43QJbRIoHQXtt10VldyQ==",
+ "integrity": "sha1-YLgTOWvjmz8SiKTB7V0efSi0ZKw=",
"dev": true,
"requires": {
"lower-case": "^1.1.1"
@@ -8144,7 +8144,7 @@
"object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
- "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
+ "integrity": "sha1-HEfyct8nfzsdrwYWd9nILiMixg4="
},
"object-visit": {
"version": "1.0.1",
@@ -8157,7 +8157,7 @@
"object.assign": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.0.tgz",
- "integrity": "sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==",
+ "integrity": "sha1-lovxEA15Vrs8oIbwBvhGs7xACNo=",
"requires": {
"define-properties": "^1.1.2",
"function-bind": "^1.1.1",
@@ -8352,7 +8352,7 @@
"p-locate": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz",
- "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==",
+ "integrity": "sha1-Mi1poFwCZLJZl9n0DNiokasAZKQ=",
"requires": {
"p-limit": "^2.0.0"
}
@@ -8365,7 +8365,7 @@
"p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
- "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ=="
+ "integrity": "sha1-yyhoVA4xPWHeWPr741zpAE1VQOY="
},
"package-hash": {
"version": "4.0.0",
@@ -8414,7 +8414,7 @@
"parent-module": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz",
- "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==",
+ "integrity": "sha1-aR0nCeeMefrjoVZiJFLQB2LKqqI=",
"dev": true,
"requires": {
"callsites": "^3.0.0"
@@ -8520,7 +8520,7 @@
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
- "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
+ "integrity": "sha1-SyzSXFDVmHNcUCkiJP2MbfQeMjE="
},
"pinkie": {
"version": "2.0.4",
@@ -8540,7 +8540,7 @@
"pkg-dir": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz",
- "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==",
+ "integrity": "sha1-J0kCDyOe2ZCIGx9xIQ1R62UjvqM=",
"requires": {
"find-up": "^3.0.0"
}
@@ -8681,7 +8681,7 @@
"punycode": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
- "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
+ "integrity": "sha1-tYsBCsQMIsVldhbI0sLALHv0eew="
},
"qs": {
"version": "6.7.0",
@@ -8803,7 +8803,7 @@
"regexpp": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-2.0.1.tgz",
- "integrity": "sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==",
+ "integrity": "sha1-jRnTHPYySCtYkEn4KB+T28uk0H8=",
"dev": true
},
"regexpu-core": {
@@ -8872,7 +8872,7 @@
"require-main-filename": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",
- "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
+ "integrity": "sha1-0LMp7MfMD2Fkn2IhW+aa9UqomJs=",
"dev": true
},
"resolve": {
@@ -9502,7 +9502,7 @@
"stack-chain": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/stack-chain/-/stack-chain-2.0.0.tgz",
- "integrity": "sha512-GGrHXePi305aW7XQweYZZwiRwR7Js3MWoK/EHzzB9ROdc75nCnjSJVi21rdAGxFl+yCx2L2qdfl5y7NO4lTyqg==",
+ "integrity": "sha1-1z0Rcq+JVl8HQ4tbzAhoMbZomy0=",
"dev": true
},
"stack-generator": {
@@ -9532,7 +9532,7 @@
"dependencies": {
"source-map": {
"version": "0.5.6",
- "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
+ "resolved": "http://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
"integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=",
"dev": true
}
@@ -9670,7 +9670,7 @@
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
- "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
+ "integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=",
"requires": {
"safe-buffer": "~5.1.0"
}
@@ -9750,7 +9750,7 @@
"table": {
"version": "5.4.6",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz",
- "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==",
+ "integrity": "sha1-EpLRlQDOP4YFOwXw6Ofko7shB54=",
"dev": true,
"requires": {
"ajv": "^6.10.2",
@@ -9768,7 +9768,7 @@
"string-width": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz",
- "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==",
+ "integrity": "sha1-InZ74htirxCBV0MG9prFG2IgOWE=",
"dev": true,
"requires": {
"emoji-regex": "^7.0.1",
@@ -9957,7 +9957,7 @@
"tmp": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
- "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
+ "integrity": "sha1-bTQzWIl2jSGyvNoKonfO07G/rfk=",
"dev": true,
"requires": {
"os-tmpdir": "~1.0.2"
@@ -10049,7 +10049,7 @@
"type-detect": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
- "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
+ "integrity": "sha1-dkb7XxiHHPu3dJ5pvTmmOI63RQw=",
"dev": true
},
"type-fest": {
@@ -10192,7 +10192,7 @@
"uri-js": {
"version": "4.2.2",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz",
- "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==",
+ "integrity": "sha1-lMVA4f93KVbiKZUHwBCupsiDjrA=",
"requires": {
"punycode": "^2.1.0"
}
@@ -10410,7 +10410,7 @@
"wide-align": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
- "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==",
+ "integrity": "sha1-rgdOa9wMFKQx6ATmJFScYzsABFc=",
"dev": true,
"requires": {
"string-width": "^1.0.2 || 2"
@@ -10534,7 +10534,7 @@
"y18n": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
- "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w=="
+ "integrity": "sha1-le+U+F7MgdAHwmThkKEg8KPIVms="
},
"yaml": {
"version": "1.7.2",
diff --git a/package.json b/package.json
index 7f1cfd5c6..60f024f0f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
- "version": "7.1.1",
+ "version": "7.1.2",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team ",
"repository": {
diff --git a/src/controllers/document.js b/src/controllers/document.js
index 6baaccd64..c6fd5e5ef 100644
--- a/src/controllers/document.js
+++ b/src/controllers/document.js
@@ -182,6 +182,13 @@ class DocumentController extends BaseController {
}
search (index, collection, body = {}, options = {}) {
+ return this._search(index, collection, body, options)
+ .then(({ response, request }) => (
+ new DocumentSearchResult(this.kuzzle, request, options, response.result)
+ ));
+ }
+
+ _search (index, collection, body = {}, options = {}) {
const request = {
index,
collection,
@@ -194,16 +201,12 @@ class DocumentController extends BaseController {
delete options[opt];
}
- if (request.size === undefined) {
- request.size = 10;
- }
-
- if (!request.scroll && !request.body.sort && !request.from) {
- request.from = 0;
+ if (!options.verb) {
+ options.verb = 'POST';
}
return this.query(request, options)
- .then(response => new DocumentSearchResult(this.kuzzle, request, options, response.result));
+ .then(response => ({ response, request }));
}
update (index, collection, _id, body, options = {}) {
diff --git a/src/controllers/searchResult/index.js b/src/controllers/searchResult/index.js
new file mode 100644
index 000000000..545b84d60
--- /dev/null
+++ b/src/controllers/searchResult/index.js
@@ -0,0 +1,15 @@
+const SearchResultBase = require('./base');
+const DocumentSearchResult = require('./document');
+const ProfileSearchResult = require('./profile');
+const RoleSearchResult = require('./role');
+const SpecificationSearchResult = require('./specifications');
+const UserSearchResult = require('./user');
+
+module.exports = {
+ SearchResultBase,
+ DocumentSearchResult,
+ ProfileSearchResult,
+ RoleSearchResult,
+ SpecificationSearchResult,
+ UserSearchResult
+};
\ No newline at end of file
diff --git a/src/protocols/http.js b/src/protocols/http.js
index 57f69ec77..0b0a8fcf8 100644
--- a/src/protocols/http.js
+++ b/src/protocols/http.js
@@ -307,8 +307,19 @@ class HttpWrapper extends KuzzleAbstractProtocol {
if (http && http.length === 1) {
routes[controller][action] = http[0];
- } else if (http && http.length > 1) {
- routes[controller][action] = getCorrectRoute(http);
+ }
+ else if (http && http.length > 1) {
+ // We need this ugly fix because the document:search route can also
+ // be accessed in GET with this url: "/:index/:collection"
+ // But to send a query, we need to pass it in the body so we need POST
+ // so we can change the verb but then POST on "/:index/:collection"
+ // is the collection:update method (document:search is "/:index/:collection/_search")
+ if (controller === 'document' && action === 'search') {
+ routes[controller][action] = getPostRoute(http);
+ }
+ else {
+ routes[controller][action] = getCorrectRoute(http);
+ }
}
}
@@ -325,7 +336,10 @@ class HttpWrapper extends KuzzleAbstractProtocol {
_warn (message) {
console.warn(message); // eslint-disable-line no-console
}
+}
+function getPostRoute (routes) {
+ return routes[0].verb === 'POST' ? routes[0] : routes[1];
}
function getCorrectRoute (routes) {
diff --git a/test/controllers/document.test.js b/test/controllers/document.test.js
index d3447d0cf..08722d6a1 100644
--- a/test/controllers/document.test.js
+++ b/test/controllers/document.test.js
@@ -382,14 +382,14 @@ describe('Document Controller', () => {
.then(res => {
should(kuzzle.query)
.be.calledOnce()
- .be.calledWith({
+ .be.calledWithMatch({
controller: 'document',
action: 'search',
index: 'index',
collection: 'collection',
body: {foo: 'bar'},
- from: 0,
- size: 10,
+ from: undefined,
+ size: undefined,
scroll: undefined
}, options);
@@ -416,7 +416,7 @@ describe('Document Controller', () => {
.then(res => {
should(kuzzle.query)
.be.calledOnce()
- .be.calledWith({
+ .be.calledWithMatch({
controller: 'document',
action: 'search',
index: 'index',
@@ -428,30 +428,13 @@ describe('Document Controller', () => {
}, {});
should(res).be.an.instanceOf(DocumentSearchResult);
- should(res._options).be.empty();
+ should(res._options).match({ verb: 'POST' });
should(res._response).be.equal(result);
should(res.fetched).be.equal(2);
should(res.total).be.equal(3);
});
});
- it('should set default value for from and size', () => {
- const result = {
- hits: [],
- total: 0
- };
- kuzzle.document.query = sinon.stub().resolves({result});
-
- return kuzzle.document.search('index', 'collection', {})
- .then(() => {
- should(kuzzle.document.query).be.calledOnce();
-
- const request = kuzzle.document.query.getCall(0).args[0];
- should(request.from).be.eql(0);
- should(request.size).be.eql(10);
- });
- });
-
it('should allow to set value of 0 for size', () => {
const result = {
hits: [],
@@ -464,7 +447,6 @@ describe('Document Controller', () => {
should(kuzzle.document.query).be.calledOnce();
const request = kuzzle.document.query.getCall(0).args[0];
- should(request.from).be.eql(0);
should(request.size).be.eql(0);
});
});
diff --git a/test/protocol/http.test.js b/test/protocol/http.test.js
index 15e594942..5f9ca09d1 100644
--- a/test/protocol/http.test.js
+++ b/test/protocol/http.test.js
@@ -721,6 +721,14 @@ describe('HTTP networking module', () => {
describe('_constructRoutes', () => {
it('should construct http routes from server:publicApi', () => {
const publicApi = {
+ document: {
+ search: {
+ http: [
+ { verb: 'GET', url: '/:index/:collection/' },
+ { verb: 'POST', url: '/:index/:collection/_search' }
+ ]
+ }
+ },
foo: {
login: {
http: [
@@ -766,8 +774,10 @@ describe('HTTP networking module', () => {
// will be in the query string
should(routes.foo.create.url).be.eql('/:index/:collection/_create');
- should(routes.foo.subscribe).be.undefined();
+ // we should choose the POST route for document:create
+ should(routes.document.search.url).be.eql('/:index/:collection/_search');
+ should(routes.foo.subscribe).be.undefined();
});
it('should overwrite kuzzle routes with custom routes', () => {