Skip to main content

Use faceted search

Faceted search is a powerful tool that allows you to filter and retrieve REST resources based on multiple criteria or attributes, such as labels, annotations, status, and dates. This is especially useful when managing large sets of resources that need to be filtered efficiently.

Here is an example of a simple faceted search using labels:

const result = await client.credentials.credentialSearch({
filter: [
{
labels: {
operator: 'EQUAL',
value: 'employment',
}
},
},
],
});

Example: Advanced faceted search with multiple criteria

The example below covers the case of finding credentials of a specific credential type (documentType) that has a specific linked verifiable credential (previouslyIssuedVC):

const result = await client.credentials.credentialSearch({
filter: [
{
data: {
type: {
operator: 'IN',
values: [documentType.getCredentialTerm()],
},
linkedCredentials: {
operator: 'IN',
values: [previouslyIssuedVC.toLinkedCredential().id],
},
},
},
],
});

Further reading