-
Notifications
You must be signed in to change notification settings - Fork 17
Support "lang" parameter for Koncorde filters #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e5fe0ad
Support lang parameter for Konkorde filters
Yoann-Abbes 1314356
fix units tests
Yoann-Abbes 7eb061c
update sdk link doc
Yoann-Abbes ffcc91e
fix links
Yoann-Abbes 42209ba
fix badges
Yoann-Abbes 1a27b12
Add snippets
Yoann-Abbes 72e1f81
fix
Yoann-Abbes 8691acc
Fix tests
Yoann-Abbes 1434584
Fix commentary
Yoann-Abbes 532558e
Merge branch '7-dev' into support-lang-parameter-for-konkorde-filters
Yoann-Abbes d3c6fa7
requested changes @rolljee
Yoann-Abbes 565f568
Update doc/7/controllers/auth/search-api-keys/index.md
Yoann-Abbes 451c476
Update doc/7/controllers/auth/search-api-keys/snippets/search-api-key…
Yoann-Abbes 1afb677
Update doc/7/controllers/auth/search-api-keys/snippets/search-api-key…
Yoann-Abbes 4a89ead
Update doc/7/controllers/document/delete-by-query/index.md
Yoann-Abbes 0f8ed67
Update doc/7/controllers/document/search/index.md
Yoann-Abbes 184c86f
Update doc/7/controllers/security/search-users/index.md
Yoann-Abbes 94cc6e6
Update doc/7/controllers/security/search-users/index.md
Yoann-Abbes 45ce532
Update src/controllers/Document.ts
Yoann-Abbes 1b8619e
Update src/controllers/Document.ts
Yoann-Abbes 944cd18
Update doc/7/controllers/document/update-by-query/index.md
Yoann-Abbes c030418
Update doc/7/controllers/security/search-api-keys/index.md
Yoann-Abbes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...pi-keys/snippets/search-api-keys.test.yml → ...keys/snippets/search-api-keys-es.test.yml
This file contains hidden or 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
66 changes: 66 additions & 0 deletions
66
doc/7/controllers/auth/search-api-keys/snippets/search-api-keys-koncorde.js
This file contains hidden or 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,66 @@ | ||
| try { | ||
| const promises = []; | ||
|
|
||
| // Create some API keys for user "jared.doe" | ||
| promises.push( | ||
| kuzzle.security.createApiKey('jared.doe', 'Sigfox API key')); | ||
| promises.push( | ||
| kuzzle.security.createApiKey('jared.doe', 'LoRa 6 month API key', { | ||
| expiresIn: 36000 | ||
| })); | ||
| promises.push( | ||
| kuzzle.security.createApiKey('jared.doe', 'LoRa permanent API key', { | ||
| expiresIn: 42000, refresh: 'wait_for' | ||
| })); | ||
|
|
||
| await Promise.all(promises); | ||
|
|
||
| // Log as "jared.doe" | ||
| await kuzzle.auth.login('local', { username: 'jared.doe', password: 'password' }); | ||
|
|
||
| const results = await kuzzle.auth.searchApiKeys({ | ||
| or: [ | ||
| { | ||
| equals: { | ||
| ttl: 42000 | ||
| } | ||
| }, | ||
| { | ||
| equals: { | ||
| ttl: 36000 | ||
| }, | ||
| } | ||
| ] | ||
| }, { lang: 'koncorde' }); | ||
|
|
||
| console.log(results); | ||
| /* | ||
| { | ||
| "total": 2, | ||
| "hits": [ | ||
| { | ||
| "_id": "znEwbG8BJASM_0-bWU-q", | ||
| "_source": { | ||
| "description": "LoRa permanent API key", | ||
| "userId": "jared.doe", | ||
| "expiresAt": 31557600000, | ||
Yoann-Abbes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "ttl": 420000 | ||
| } | ||
| }, | ||
| { | ||
| "_id": "zXEwbG8BJASM_0-bWU-q", | ||
| "_source": { | ||
| "description": "LoRa 1 year API key", | ||
| "userId": "jared.doe", | ||
| "expiresAt": 31557600000, | ||
Yoann-Abbes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "ttl": 420000 | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| */ | ||
|
|
||
| console.log(`Found ${results.total} API keys.`); | ||
| } catch (e) { | ||
| console.error(e); | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
doc/7/controllers/auth/search-api-keys/snippets/search-api-keys-koncorde.test.yml
This file contains hidden or 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,20 @@ | ||
| name: auth#searchApiKeys-koncorde | ||
| description: Searches API keys for the currently loggued user. | ||
| hooks: | ||
| before: > | ||
| curl --fail -H "Content-type: application/json" -d '{ | ||
| "content": { | ||
| "profileIds": ["default"] | ||
| }, | ||
| "credentials": { | ||
| "local": { | ||
| "username": "jared.doe", | ||
| "password": "password" | ||
| } | ||
| } | ||
| }' "kuzzle:7512/users/jared.doe/_create?refresh=wait_for" | ||
| after: | ||
| curl -XDELETE kuzzle:7512/users/jared.doe | ||
| template: default | ||
| expected: | ||
| - Found 2 API keys. |
This file contains hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
...y-query/snippets/delete-by-query.test.yml → ...uery/snippets/delete-by-query-es.test.yml
This file contains hidden or 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
14 changes: 14 additions & 0 deletions
14
doc/7/controllers/document/delete-by-query/snippets/delete-by-query-koncorde.js
This file contains hidden or 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,14 @@ | ||
| try { | ||
| const deleted = await kuzzle.document.deleteByQuery( | ||
| 'nyc-open-data', | ||
| 'yellow-taxi', { | ||
| query: { | ||
| equals: { capacity: 7 } | ||
| } | ||
| }, { lang: 'koncorde' } | ||
| ); | ||
|
|
||
| console.log(`Successfully deleted ${deleted.length} documents`); | ||
| } catch (error) { | ||
| console.error(error.message); | ||
| } | ||
|
||
20 changes: 20 additions & 0 deletions
20
doc/7/controllers/document/delete-by-query/snippets/delete-by-query-koncorde.test.yml
This file contains hidden or 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,20 @@ | ||
| name: document#deleteByQuery-koncorde | ||
| description: Delete documents matching query | ||
| 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 | ||
|
|
||
| for i in 1 2 3 4 5; do | ||
| curl --fail -H "Content-type: application/json" -d '{"capacity": 4}' kuzzle:7512/nyc-open-data/yellow-taxi/_create | ||
| done | ||
|
|
||
| for i in 1 2 3 4 5; do | ||
| curl --fail -H "Content-type: application/json" -d '{"capacity": 7}' kuzzle:7512/nyc-open-data/yellow-taxi/_create | ||
| done | ||
|
|
||
| curl -XPOST kuzzle:7512/nyc-open-data/yellow-taxi/_refresh | ||
| after: | ||
| template: default | ||
| expected: Successfully deleted 5 documents |
This file contains hidden or 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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../document/search/snippets/search.test.yml → ...cument/search/snippets/search-es.test.yml
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: document#search | ||
| name: document#search-with-es | ||
| description: Search for documents | ||
| hooks: | ||
| before: | | ||
|
|
||
60 changes: 60 additions & 0 deletions
60
doc/7/controllers/document/search/snippets/search-koncorde.js
This file contains hidden or 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,60 @@ | ||
| const suv = { category: 'suv' }; | ||
| const limousine = { category: 'limousine' }; | ||
|
|
||
| try { | ||
| const requests = []; | ||
|
|
||
| for (let i = 0; i < 5; i++) { | ||
| requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', suv)); | ||
| } | ||
| for (let i = 0; i < 10; i++) { | ||
| requests.push(kuzzle.document.create('nyc-open-data', 'yellow-taxi', limousine)); | ||
| } | ||
| await Promise.all(requests); | ||
|
|
||
| await kuzzle.collection.refresh('nyc-open-data', 'yellow-taxi'); | ||
|
|
||
| const options = { lang: 'koncorde' }; | ||
|
|
||
| const results = await kuzzle.document.search( | ||
| 'nyc-open-data', | ||
| 'yellow-taxi', | ||
| { | ||
| query: { | ||
| equals: { | ||
| category: 'suv' | ||
| } | ||
| } | ||
| }, | ||
| options | ||
| ); | ||
|
|
||
| console.log(results); | ||
| /* | ||
| { | ||
| "aggregations": undefined, | ||
| "hits": [ | ||
| { | ||
| "_id": "AWgi6A1POQUM6ucJ3q06", | ||
| "_score": 0.046520017, | ||
| "_source": { | ||
| "category": "suv", | ||
| "_kuzzle_info": { | ||
| "author": "-1", | ||
| "createdAt": 1546773859655, | ||
| "updatedAt": null, | ||
| "updater": null | ||
| } | ||
| } | ||
| }, | ||
| ... | ||
| ] | ||
| }, | ||
| "total": 5, | ||
| "fetched": 5, | ||
| "scroll_id": undefined | ||
| */ | ||
| console.log(`Successfully retrieved ${results.total} documents`); | ||
| } catch (error) { | ||
| console.error(error.message); | ||
| } |
10 changes: 10 additions & 0 deletions
10
doc/7/controllers/document/search/snippets/search-koncorde.test.yml
This file contains hidden or 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,10 @@ | ||
| name: document#search-with-koncorde | ||
| description: Search for documents | ||
| 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: | ||
| template: default | ||
| expected: Successfully retrieved 5 documents |
This file contains hidden or 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
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.