open-index/open-npm huggingface dataset:
npm package: @kamlendra/search-vocab
Description: Entity Search Vocabulary for CAP applications with getEntities and getSchema default implementations
Author: ACME Corp
Latest version: 1.0.0

# Search Vocab Plugin

A comprehensive CAP plugin for entity search integration with built-in schema discovery service.

## Installation

```bash
npm install @acme/search-vocab
```

## Usage

### 1. Include in your CDS model

```cds
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 entities
- `POST /SchemaService/refreshSearchCache()` - Refresh discovery cache
- `GET /SchemaService/SearchEntities` - Query discovered entities
- `GET /SchemaService/SearchFields` - Query search field configurations

### 4. Consumer Integration

```javascript
// 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.