Skip to content

Commit

Permalink
fix unit test + add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Oct 2, 2019
1 parent aa108ec commit 3589d3c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/api/saved-objects/find.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"`);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3589d3c

Please sign in to comment.