Files
medusa-store/www/apps/docs/content/references/services/classes/SearchService.mdx
github-actions[bot] cdd42dbdcd chore(docs): Generated References (#5743)
Generated the following references:
- `entities`
- `inventory`
- `js-client`
- `pricing`
- `product`
- `services`
- `stock-location`
- `workflows`

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2023-11-27 18:58:52 +00:00

460 lines
8.5 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# SearchService
## Constructors
#### constructor
`**new SearchService**(«destructured», options)`
##### Parameters
<ParameterTypes parameters={[
{
"name": "__namedParameters",
"type": "[InjectedDependencies](../types/InjectedDependencies-36.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Properties
<ParameterTypes parameters={[
{
"name": "isDefault",
"type": "`boolean`",
"description": "",
"optional": false,
"defaultValue": "true",
"expandable": false,
"children": []
},
{
"name": "logger_",
"type": "[Logger](../types/Logger-1.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options_",
"type": "`Record<string, unknown>`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Accessors
#### options
**options**: [object Object]
## Methods
#### addDocuments
`**addDocuments**(indexName, documents, type): Promise&#60;void&#62;`
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
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />
___
#### createIndex
`**createIndex**(indexName, options): Promise&#60;void&#62;`
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
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />
___
#### deleteAllDocuments
`**deleteAllDocuments**(indexName): Promise&#60;void&#62;`
Used to delete all documents
##### Parameters
<ParameterTypes parameters={[
{
"name": "indexName",
"type": "`string`",
"description": "the index name",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
##### Returns
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />
___
#### deleteDocument
`**deleteDocument**(indexName, document_id): Promise&#60;void&#62;`
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
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />
___
#### getIndex
`**getIndex**(indexName): Promise&#60;void&#62;`
Used to get an index
##### Parameters
<ParameterTypes parameters={[
{
"name": "indexName",
"type": "`string`",
"description": "the index name.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
##### Returns
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />
___
#### replaceDocuments
`**replaceDocuments**(indexName, documents, type): Promise&#60;void&#62;`
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
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />
___
#### search
`**search**(indexName, query, options): Promise&#60;&#123; hits: unknown[] &#125;&#62;`
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": "`unknown`",
"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
Promise&#60;&#123; hits: unknown[] &#125;&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;&#123; hits: unknown[] &#125;&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />
___
#### updateSettings
`**updateSettings**(indexName, settings): Promise&#60;void&#62;`
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
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "returns response from search engine provider",
"expandable": false,
"children": []
}
]} />