-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from kuzzleio/7.2.0-proposal
# [7.2.0](https://github.com/kuzzleio/sdk-javascript/releases/tag/7.2.0) (2020-04-28) #### Bug fixes - [ [#508](#508) ] Fix SearchResult.next with sort/size ([Aschen](https://github.com/Aschen)) - [ [#512](#512) ] Fix token expired ([Aschen](https://github.com/Aschen)) - [ [#511](#511) ] Avoid to mutate user options ([Aschen](https://github.com/Aschen)) - [ [#507](#507) ] Fix collection getMapping ([Aschen](https://github.com/Aschen)) #### New features - [ [#510](#510) ] Add security:refresh ([Yoann-Abbes](https://github.com/Yoann-Abbes)) #### Enhancements - [ [#509](#509) ] Add the rate limit property to Profile objects ([scottinet](https://github.com/scottinet)) ---
- Loading branch information
Showing
37 changed files
with
507 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
code: true | ||
type: page | ||
title: refresh | ||
--- | ||
|
||
# refresh | ||
|
||
Forces an immediate [reindexation](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/docs-refresh.html) of the provided security collection. | ||
|
||
The available security collections are: `users`, `profiles`, `roles`. | ||
|
||
When writing or deleting documents in Kuzzle, the changes need to be indexed before being reflected in the search results. | ||
By default, this operation can take up to 1 second. | ||
|
||
::: warning | ||
Forcing immediate refreshes comes with performance costs, and should only performed when absolutely necessary. | ||
::: | ||
|
||
|
||
```js | ||
refresh(collection); | ||
``` | ||
|
||
## Arguments | ||
|
||
- `collection`: collection name to refresh | ||
|
||
## Resolves | ||
|
||
Resolves when the refresh has been done. | ||
|
||
## Usage | ||
|
||
<<< ./snippets/refresh.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
try { | ||
await kuzzle.security.refresh('users'); | ||
console.log('Success'); | ||
} catch (e) { | ||
console.error(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: security#refresh | ||
description: Refreshes security collection | ||
hooks: | ||
template: default | ||
expected: Success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
doc/7/core-classes/search-result/next/snippets/sortsize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
try { | ||
const documents = []; | ||
|
||
for (let i = 0; i < 100; i++) { | ||
documents.push({ _id: `suv_no${i}`, body: { category: 'suv' } }); | ||
} | ||
|
||
await kuzzle.document.mCreate('nyc-open-data', 'yellow-taxi', documents, { | ||
refresh: 'wait_for' | ||
}); | ||
|
||
let results = await kuzzle.document.search( | ||
'nyc-open-data', | ||
'yellow-taxi', | ||
{ | ||
query: { match: { category: 'suv' } }, | ||
sort: [ | ||
{ '_kuzzle_info.createdAt': 'desc' }, | ||
'_id' | ||
] | ||
}, | ||
{ size: 5 }); | ||
|
||
// Fetch the matched items by advancing through the result pages | ||
const matched = []; | ||
|
||
while (results) { | ||
matched.push(...results.hits); | ||
results = await results.next(); | ||
} | ||
|
||
console.log(matched[0]); | ||
/* | ||
{ _id: 'suv_no1', | ||
_score: 0.03390155, | ||
_source: | ||
{ _kuzzle_info: | ||
{ author: '-1', | ||
updater: null, | ||
updatedAt: null, | ||
createdAt: 1570093133057 }, | ||
category: 'suv' } } | ||
*/ | ||
console.log(`Successfully retrieved ${matched.length} documents`); | ||
} catch (error) { | ||
console.error(error.message); | ||
} |
11 changes: 11 additions & 0 deletions
11
doc/7/core-classes/search-result/next/snippets/sortsize.test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: searchresult#sortsize | ||
description: Next method with sort/size | ||
hooks: | ||
before: | | ||
curl -XDELETE kuzzle:7512/nyc-open-data | ||
curl -XPOST kuzzle:7512/nyc-open-data/_create | ||
curl -XPUT kuzzle:7512/nyc-open-data/yellow-taxi | ||
after: | | ||
curl -XDELETE kuzzle:7512/nyc-open-data | ||
template: default | ||
expected: Successfully retrieved 100 documents |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.