# Class QueryController

This class is automatically instantiated and bound to the root of your search interface when you initialize the framework.
It is essentially a singleton that wraps the access to the SearchEndpoint endpoint to execute query, and is in charge of triggering the different query events.
This is what every component of the framework uses internally to execute query or access the endpoint.
When calling `Coveo.executeQuery` this class is used.

## Index

### Methods

- cancelQuery
- debugInfo
- disable
- enable
- executeQuery
- fetchMore
- fetchQueryExecutionPlan
- getEndpoint
- getLastQuery
- getLastResults
- setEndpoint

### Properties

- disabled
- logger
- ID

### Constructors

- constructor

## Methods

### cancelQuery

- cancelQuery(): void

- - Defined in controllers/QueryController.ts :416

  Cancel any pending query

  #### Returns void

### debugInfo

- debugInfo(): any

- Inherited from BaseComponent.debugInfo

  - Defined in ui/Base/BaseComponent.ts :41

  Return the debug info about this component.

  #### Returns any

### disable

- disable(): void

- Inherited from BaseComponent.disable

  - Defined in ui/Base/BaseComponent.ts :52

  Disable the component. Normally this means that the component will not execute handlers for the framework events (query events, for example). Components are enabled by default on creation.

  #### Returns void

### enable

- enable(): void

- Inherited from BaseComponent.enable

  - Defined in ui/Base/BaseComponent.ts :61

  Enable the component. Normally this means that the component will execute handlers for the framework events (query events, for example). Components are enabled by default on creation.

  #### Returns void

### executeQuery

- executeQuery(options?: IQueryOptions): Promise<IQueryResults>

- - Defined in controllers/QueryController.ts :198

  Execute a query and return a Promise of IQueryResults.
  This will execute the normal query flow, triggering all the necessary query events (newQuery
  All components present in the interface will act accordingly (modify the query and render results if needed).

  #### Parameters

  - ##### Optional options: IQueryOptions

  #### Returns Promise<IQueryResults>

### fetchMore

- fetchMore(count: number): Promise<IQueryResults>

- - Defined in controllers/QueryController.ts :357

  Using the same parameters as the last successful query, fetch another batch of results. Particularly useful for infinite scrolling, for example.

  #### Parameters

  - ##### count: number

  #### Returns Promise<IQueryResults>

### fetchQueryExecutionPlan

- fetchQueryExecutionPlan(): Promise<ExecutionPlan>

- - Defined in controllers/QueryController.ts :181

  Returns the plan of execution of a search request, without executing it.

  #### Returns Promise<ExecutionPlan>

### getEndpoint

- getEndpoint(): ISearchEndpoint

- - Defined in controllers/QueryController.ts :152

  Get the SearchEndpoint that is currently used by the query controller to execute query

  #### Returns ISearchEndpoint

### getLastQuery

- getLastQuery(): IQuery

- - Defined in controllers/QueryController.ts :165

  Return the last query that was performed by the query controller

  #### Returns IQuery

### getLastResults

- getLastResults(): IQueryResults

- - Defined in controllers/QueryController.ts :173

  Return the last query results set.

  #### Returns IQueryResults

### setEndpoint

- setEndpoint(endpoint: SearchEndpoint): void

- - Defined in controllers/QueryController.ts :143

  Set the SearchEndpoint that the query controller should use to execute query

  #### Parameters

  - ##### endpoint: SearchEndpoint

  #### Returns void

## Properties

### disabled

disabled: boolean

Inherited from BaseComponent.disabled

- Defined in ui/Base/BaseComponent.ts :23

A disabled component will not participate in the query, or listen to ComponentEvents.

type

  {boolean}

### logger

logger: Logger

Inherited from BaseComponent.logger

- Defined in ui/Base/BaseComponent.ts :18

Allows component to log in the dev console.

### Static ID

ID: string

Inherited from BaseComponent.ID

- Defined in ui/Base/BaseComponent.ts :28

The static ID that each component needs in order to be identified.
For example, SearchButton -> static ID: SearchButton -> className: CoveoSearchButton

## Constructors

### constructor

- new QueryController(element: HTMLElement, options: ISearchInterfaceOptions, usageAnalytics: IAnalyticsClient, searchInterface: SearchInterface): QueryController

- - Defined in controllers/QueryController.ts :113

  Create a new query controller

  #### Parameters

  - ##### element: HTMLElement

  - ##### options: ISearchInterfaceOptions

  - ##### usageAnalytics: IAnalyticsClient

    Deprecated. Since the October 2019 Release (v2.7219), the class retrieves and uses the {@link AnalyticsClient} from its `searchInterface` constructor parameter.

  - ##### searchInterface: SearchInterface

  #### Returns QueryController

### Hierarchy

- RootComponent