Files
medusa-store/www/apps/docs/content/references/services/classes/SearchService.mdx
Shahed Nasser c6dff873de docs: update docusaurus to v3 (#5625)
* update dependencies

* update onboarding mdx

* fixes for mdx issues

* fixes for mdx compatibility

* resolve mdx errors

* fixes in reference

* fix check errors

* revert change in vale action

* fix node version in action

* fix summary in markdown
2023-11-13 20:11:50 +02:00

476 lines
8.7 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
`get**options**(): Record&#60;string, unknown&#62;`
#### Returns
`Record<string, unknown>`
<ParameterTypes parameters={[
{
"name": "Record",
"type": "`Record<string, unknown>`",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
## 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": []
}
]} />