@kamlendra/search-vocab
v1.0.0
Published
Entity Search Vocabulary for CAP applications with getEntities and getSchema default implementations
Maintainers
Readme
Search Vocab Plugin
A comprehensive CAP plugin for entity search integration with built-in schema discovery service.
Installation
npm install @acme/search-vocabUsage
1. Include in your CDS model
using { search } from '@acme/search-vocab';
using from '@acme/search-vocab/schema-service';
// Your entity with search annotations
@search.entity.group : 'Product Catalog'
entity ProductView as select from Products {
@search.autocomplete
@search.autocomplete.asfilter
key ID,
@search.autocomplete
name
};
// Configure search behavior
annotate ProductView with @search.entity : {
protocol : 'ODATA',
paths : [{
name: 'productSearch',
path : '/odata/v4/myservice/ProductView',
queryParams : {
filterFields : ['category'],
queryFields : ['name', 'description']
}
}],
navigations : [{
name : 'ProductDetails',
semanticObject : 'Product',
action : 'display',
route : '/products/${ID}'
}],
roles : [{
role : 'Buyer',
target : 'ProductDetails',
autocomplete : 'productSearch'
}]
};2. Available Annotations
Entity Level
@search.entity- Main search configuration@search.entity.group- Grouping for search UI@search.service- Mark service as search provider
Field Level
@search.autocomplete- Include in autocomplete@search.autocomplete.asfilter- Make field filterable@search.autocomplete.asfilter.expression- Custom filter expression
3. Built-in SchemaService
The plugin automatically provides a SchemaService with these endpoints:
POST /SchemaService/discoverSearchServices()- Discover all search entitiesPOST /SchemaService/refreshSearchCache()- Refresh discovery cacheGET /SchemaService/SearchEntities- Query discovered entitiesGET /SchemaService/SearchFields- Query search field configurations
4. Consumer Integration
// Connect to remote search schema
const schemaService = await cds.connect.to('SchemaService');
const searchConfig = await schemaService.send('discoverSearchServices');Configuration Types
See the vocabulary definitions in index.cds for complete type definitions.
Examples
Check the examples/ directory for complete implementation samples.
