# Query

**Kind**: interface | **Module**: [Search](https://docs.interop.io/desktop/reference/javascript/search/index.md)

**Source**: https://docs.interop.io/desktop/reference/javascript/search/query/index.html

Describes a created search query.

## Methods

### cancel

Cancels the search query.

```ts
() => Promise<void>
```

**Returns**: `Promise<void>`

### onCompleted

Notifies when the search query is completed, i.e. when all search operations
in all search providers have been completed.

```ts
(callback: () => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`() => void`, required)
  Callback function for handling the event.

**Returns**: `UnsubscribeFunction`

### onError

Notifies when there is an error in the search process.

```ts
(callback: (error: QueryError) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(error: QueryError) => void`, required)
  Callback function for handling the event. Receives as an argument an object holding
  the error message sent by the search provider and data describing the provider that has sent the error.

**Returns**: `UnsubscribeFunction`

### onResults

Notifies when a batch with results from the search query is received.

```ts
(callback: (resultBatch: QueryResultBatch) => void) => UnsubscribeFunction
```

**Parameters**

- **`callback`** (`(resultBatch: QueryResultBatch) => void`, required)
  Callback function for handling the event. Receives as an argument an object holding
  a list of the available search result and details about the search provider that has sent the results.

**Returns**: `UnsubscribeFunction`

## Related types

- [QueryError](https://docs.interop.io/desktop/reference/javascript/search/queryerror/index.md)
- [QueryResultBatch](https://docs.interop.io/desktop/reference/javascript/search/queryresultbatch/index.md)
- [UnsubscribeFunction](https://docs.interop.io/desktop/reference/javascript/search/unsubscribefunction/index.md)
