-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
savedObjects: add score
to repository.find results
#68894
Changes from 7 commits
3b7a75a
0739d12
ed01c87
99924a1
aa3afed
7be930b
4d07c7b
72328b8
69df796
49a88b4
dc2f9b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsFindResult](./kibana-plugin-core-server.savedobjectsfindresult.md) | ||
|
||
## SavedObjectsFindResult interface | ||
|
||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface SavedObjectsFindResult<T = unknown> extends SavedObject<T> | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [score](./kibana-plugin-core-server.savedobjectsfindresult.score.md) | <code>number</code> | The ES search's <code>_score</code> of this result. | | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [SavedObjectsFindResult](./kibana-plugin-core-server.savedobjectsfindresult.md) > [score](./kibana-plugin-core-server.savedobjectsfindresult.score.md) | ||
|
||
## SavedObjectsFindResult.score property | ||
|
||
The ES search's `_score` of this result. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
score: number; | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,8 +116,11 @@ async function fetchObjectsToExport({ | |
} | ||
|
||
// sorts server-side by _id, since it's only available in fielddata | ||
return findResponse.saved_objects.sort((a: SavedObject, b: SavedObject) => | ||
a.id > b.id ? 1 : -1 | ||
return ( | ||
findResponse.saved_objects | ||
// exclude the find-specific `score` property from the exported objects | ||
.map(({ score, ...obj }) => obj) | ||
.sort((a: SavedObject, b: SavedObject) => (a.id > b.id ? 1 : -1)) | ||
Comment on lines
+121
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was the only significant API where we need to remove |
||
); | ||
} else { | ||
throw Boom.badRequest('Either `type` or `objects` are required.'); | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -79,6 +79,17 @@ export interface SavedObjectsBulkResponse<T = unknown> { | |||||
saved_objects: Array<SavedObject<T>>; | ||||||
} | ||||||
|
||||||
/** | ||||||
* | ||||||
* @public | ||||||
*/ | ||||||
export interface SavedObjectsFindResult<T = unknown> extends SavedObject<T> { | ||||||
/** | ||||||
* The ES search's `_score` of this result. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I think it's better to rather use the full name for Elasticsearch |
||||||
*/ | ||||||
score: number; | ||||||
rudolf marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
/** | ||||||
* Return type of the Saved Objects `find()` method. | ||||||
* | ||||||
|
@@ -88,7 +99,7 @@ export interface SavedObjectsBulkResponse<T = unknown> { | |||||
* @public | ||||||
*/ | ||||||
export interface SavedObjectsFindResponse<T = unknown> { | ||||||
saved_objects: Array<SavedObject<T>>; | ||||||
saved_objects: Array<SavedObjectsFindResult<T>>; | ||||||
total: number; | ||||||
per_page: number; | ||||||
page: number; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ export default function ({ getService }) { | |
attributes: { | ||
title: 'Count of requests', | ||
}, | ||
score: 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this is a little scary on the relevance of this PR to be honest. I had to add the When testing from the saved object management table page, I did have some non-zero @rudolf any thoughts on that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we don't have any integration tests that actually specify a search query in the |
||
migrationVersion: resp.body.saved_objects[0].migrationVersion, | ||
references: [ | ||
{ | ||
|
@@ -134,6 +135,7 @@ export default function ({ getService }) { | |
.searchSourceJSON, | ||
}, | ||
}, | ||
score: 0, | ||
references: [ | ||
{ | ||
name: 'kibanaSavedObjectMeta.searchSourceJSON.index', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,6 +371,7 @@ describe('getAll()', () => { | |
foo: 'bar', | ||
}, | ||
}, | ||
score: 1, | ||
references: [], | ||
}, | ||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1667,6 +1667,7 @@ describe('find()', () => { | |
}, | ||
], | ||
}, | ||
score: 1, | ||
references: [ | ||
{ | ||
name: 'action_0', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client-side version of the SO client is quite different from the server-side's. Most notable difference is that it returns the objects wrapped into a
SimpleSavedObject
class. Adding thescore
property on the client-sidefind
results probably means more significant changes, as we would have to extend thisSimpleSavedObject
class to add thescore
property, which is a little more complex and subject to side effects than just extending a type as it's done on the server-sideAs our current need for
score
is on the server-side anyway (at least atm), I'm just ignoring thescore
on the client-sidefind
.This decision is still open to discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, hopefully we can change this client-side API sometime in the future.