diff --git a/docs/api/saved-objects/find.asciidoc b/docs/api/saved-objects/find.asciidoc index fd80951b1c9f2..f20ded78e0743 100644 --- a/docs/api/saved-objects/find.asciidoc +++ b/docs/api/saved-objects/find.asciidoc @@ -41,6 +41,11 @@ experimental[] Retrieve a paginated set of {kib} saved objects by various condit `has_reference`:: (Optional, object) Filters to objects that have a relationship with the type and ID combination. +`filter`:: + (Optional, string) The filter is a KQL string with the caveat that if you filter with an attribute from your type saved object. + It should look like that savedObjectType.attributes.title: "myTitle". However, If you used a direct attribute of a saved object like `updatedAt`, + you will have to define your filter like that savedObjectType.updatedAt > 2018-12-22. + NOTE: As objects change in {kib}, the results on each page of the response also change. Use the find API for traditional paginated results, but avoid using it to export large amounts of data. diff --git a/src/core/server/saved_objects/service/lib/filter_utils.test.ts b/src/core/server/saved_objects/service/lib/filter_utils.test.ts index 1148c7f9acbc2..73a0804512ed1 100644 --- a/src/core/server/saved_objects/service/lib/filter_utils.test.ts +++ b/src/core/server/saved_objects/service/lib/filter_utils.test.ts @@ -131,14 +131,14 @@ describe('Filter Utils', () => { mockIndexPatterns ); }).toThrowErrorMatchingInlineSnapshot( - `"This key 'updatedAt' need to be wrapped by a saved object type like foo,bar"` + `"This key 'updatedAt' need to be wrapped by a saved object type like foo,bar: Bad Request"` ); }); test('Lets make sure that we are throwing an exception if we are using hiddentype with types', () => { expect(() => { validateConvertFilterToKueryNode([], 'hiddentype.title: "title"', mockIndexPatterns); - }).toThrowErrorMatchingInlineSnapshot(`"This type hiddentype is not allowed"`); + }).toThrowErrorMatchingInlineSnapshot(`"This type hiddentype is not allowed: Bad Request"`); }); }); diff --git a/src/core/server/saved_objects/service/lib/repository.test.js b/src/core/server/saved_objects/service/lib/repository.test.js index c0c471ad40ea5..bc646c8c1d2e1 100644 --- a/src/core/server/saved_objects/service/lib/repository.test.js +++ b/src/core/server/saved_objects/service/lib/repository.test.js @@ -1163,7 +1163,7 @@ describe('SavedObjectsRepository', () => { callAdminCluster.mockReturnValue(noNamespaceSearchResults); expect(savedObjectsRepository.find({ type: 'foo', filter: 'foo.type: hello' })) .rejects - .toThrowErrorMatchingInlineSnapshot('"options.filter is missing index pattern to work correctly"'); + .toThrowErrorMatchingInlineSnapshot('"options.filter is missing index pattern to work correctly: Bad Request"'); }); it('passes mappings, schema, search, defaultSearchOperator, searchFields, type, sortField, sortOrder and hasReference to getSearchDsl',