---
displayed_sidebar: servicesSidebar
---

import ParameterTypes from "@site/src/components/ParameterTypes"

# AbstractSearchService

## Implements

- [`ISearchService`](../interfaces/ISearchService.mdx)

## Constructors

### constructor

`Protected` **new AbstractSearchService**(`container`, `options`)

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "container",
    "type": "`any`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "options",
    "type": "`any`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Properties

<ParameterTypes parameters={[
  {
    "name": "isDefault",
    "type": "`any`",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "options_",
    "type": "Record<`string`, `unknown`\\>",
    "description": "",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

## Accessors

### options

`get` **options**(): Record<`string`, `unknown`\>

#### Returns

Record<`string`, `unknown`\>

<ParameterTypes parameters={[
  {
    "name": "Record",
    "type": "Record<`string`, `unknown`\\>",
    "optional": false,
    "defaultValue": "",
    "description": "",
    "expandable": false,
    "children": []
  }
]} />

## Methods

### addDocuments

`Abstract` **addDocuments**(`indexName`, `documents`, `type`): `unknown`

Used to index documents by the search engine provider

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "documents",
    "type": "`unknown`",
    "description": "documents array to be indexed",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "type",
    "type": "`string`",
    "description": "of documents to be added (e.g: products, regions, orders, etc)",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />

___

### createIndex

`Abstract` **createIndex**(`indexName`, `options`): `unknown`

Used to create an index

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "options",
    "type": "`unknown`",
    "description": "the options",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />

___

### deleteAllDocuments

`Abstract` **deleteAllDocuments**(`indexName`): `unknown`

Used to delete all documents

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />

___

### deleteDocument

`Abstract` **deleteDocument**(`indexName`, `document_id`): `unknown`

Used to delete document

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "document_id",
    "type": "`string` \\| `number`",
    "description": "the id of the document",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />

___

### getIndex

`Abstract` **getIndex**(`indexName`): `unknown`

Used to get an index

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />

___

### replaceDocuments

`Abstract` **replaceDocuments**(`indexName`, `documents`, `type`): `unknown`

Used to replace documents

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name.",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "documents",
    "type": "`unknown`",
    "description": "array of document objects that will replace existing documents",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "type",
    "type": "`string`",
    "description": "type of documents to be replaced (e.g: products, regions, orders, etc)",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />

___

### search

`Abstract` **search**(`indexName`, `query`, `options`): `unknown`

Used to search for a document in an index

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "query",
    "type": "``null`` \\| `string`",
    "description": "the search query",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "options",
    "type": "`unknown`",
    "description": "any options passed to the request object other than the query and indexName - additionalOptions contain any provider specific options",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />

___

### updateSettings

`Abstract` **updateSettings**(`indexName`, `settings`): `unknown`

Used to update the settings of an index

#### Parameters

<ParameterTypes parameters={[
  {
    "name": "indexName",
    "type": "`string`",
    "description": "the index name",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  },
  {
    "name": "settings",
    "type": "`unknown`",
    "description": "settings object",
    "optional": false,
    "defaultValue": "",
    "expandable": false,
    "children": []
  }
]} />

#### Returns

`unknown`

<ParameterTypes parameters={[
  {
    "name": "unknown",
    "type": "`unknown`",
    "optional": true,
    "defaultValue": "",
    "description": "returns response from search engine provider",
    "expandable": false,
    "children": []
  }
]} />
