---
editLink: false
lastUpdated: false
---

[@salesforce/b2c-tooling-sdk](../../modules.md) / [cli](../index.md) / CommandSearchIndex

# Class: CommandSearchIndex

Defined in: [packages/b2c-tooling-sdk/src/cli/command-search.ts:157](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/bceb8da43dd8bc63d57932bbd905d36a1b40c949/packages/b2c-tooling-sdk/src/cli/command-search.ts#L157)

Searchable index over CLI commands.

## Example

```typescript
import {CommandSearchIndex} from '@salesforce/b2c-tooling-sdk/cli';

// Inside an oclif command:
const index = new CommandSearchIndex(this.config.commands, this.config.topics);
const results = index.search('deploy cartridges', {bin: this.config.bin});
```

## Constructors

### Constructor

> **new CommandSearchIndex**(`commands`, `topics`): `CommandSearchIndex`

Defined in: [packages/b2c-tooling-sdk/src/cli/command-search.ts:161](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/bceb8da43dd8bc63d57932bbd905d36a1b40c949/packages/b2c-tooling-sdk/src/cli/command-search.ts#L161)

#### Parameters

##### commands

readonly [`SearchableCommand`](../interfaces/SearchableCommand.md)[]

##### topics

readonly [`SearchableTopic`](../interfaces/SearchableTopic.md)[] = `[]`

#### Returns

`CommandSearchIndex`

## Accessors

### size

#### Get Signature

> **get** **size**(): `number`

Defined in: [packages/b2c-tooling-sdk/src/cli/command-search.ts:197](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/bceb8da43dd8bc63d57932bbd905d36a1b40c949/packages/b2c-tooling-sdk/src/cli/command-search.ts#L197)

Number of indexed (non-hidden) commands.

##### Returns

`number`

## Methods

### search()

> **search**(`query`, `options`): [`CommandSearchResult`](../interfaces/CommandSearchResult.md)[]

Defined in: [packages/b2c-tooling-sdk/src/cli/command-search.ts:208](https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/blob/bceb8da43dd8bc63d57932bbd905d36a1b40c949/packages/b2c-tooling-sdk/src/cli/command-search.ts#L208)

Search commands by free-text query.

#### Parameters

##### query

`string`

Free-text query (e.g. `deploy cartridges`, `sandbox reset`)

##### options

[`CommandSearchOptions`](../interfaces/CommandSearchOptions.md) = `{}`

Result limit, topic filter, and binary name

#### Returns

[`CommandSearchResult`](../interfaces/CommandSearchResult.md)[]

Matching commands, best first
