Skip to main content

Class: SearchService

Hierarchy

  • AbstractSearchService

    SearchService

Constructors

constructor

new SearchService(__namedParameters, options)

Parameters

NameType
__namedParametersInjectedDependencies
optionsany

Overrides

AbstractSearchService.constructor

Defined in

packages/medusa/src/services/search.ts:18

Properties

__configModule__

Protected Optional Readonly __configModule__: Record<string, unknown>

Inherited from

AbstractSearchService.__configModule__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:10


__container__

Protected Readonly __container__: any

Inherited from

AbstractSearchService.__container__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:9


__moduleDeclaration__

Protected Optional Readonly __moduleDeclaration__: Record<string, unknown>

Inherited from

AbstractSearchService.__moduleDeclaration__

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:11


isDefault

isDefault: boolean = true

Overrides

AbstractSearchService.isDefault

Defined in

packages/medusa/src/services/search.ts:11


logger_

Protected Readonly logger_: Logger

Defined in

packages/medusa/src/services/search.ts:15


manager_

Protected manager_: EntityManager

Overrides

AbstractSearchService.manager_

Defined in

packages/medusa/src/services/search.ts:13


options_

Protected Readonly options_: Record<string, unknown>

Overrides

AbstractSearchService.options_

Defined in

packages/medusa/src/services/search.ts:16


transactionManager_

Protected transactionManager_: undefined | EntityManager

Overrides

AbstractSearchService.transactionManager_

Defined in

packages/medusa/src/services/search.ts:14

Accessors

options

get options(): Record<string, unknown>

Returns

Record<string, unknown>

Inherited from

AbstractSearchService.options

Defined in

packages/medusa/src/interfaces/search-service.ts:82

Methods

addDocuments

addDocuments(indexName, documents, type): Promise<void>

Parameters

NameType
indexNamestring
documentsunknown
typestring

Returns

Promise<void>

Overrides

AbstractSearchService.addDocuments

Defined in

packages/medusa/src/services/search.ts:43


atomicPhase_

Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>

Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.

Type parameters

Name
TResult
TError

Parameters

NameTypeDescription
work(transactionManager: EntityManager) => Promise<TResult>the transactional work to be done
isolationOrErrorHandler?IsolationLevel | (error: TError) => Promise<void | TResult>the isolation level to be used for the work.
maybeErrorHandlerOrDontFail?(error: TError) => Promise<void | TResult>Potential error handler

Returns

Promise<TResult>

the result of the transactional work

Inherited from

AbstractSearchService.atomicPhase_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:50


createIndex

createIndex(indexName, options): Promise<void>

Parameters

NameType
indexNamestring
optionsunknown

Returns

Promise<void>

Overrides

AbstractSearchService.createIndex

Defined in

packages/medusa/src/services/search.ts:31


deleteAllDocuments

deleteAllDocuments(indexName): Promise<void>

Parameters

NameType
indexNamestring

Returns

Promise<void>

Overrides

AbstractSearchService.deleteAllDocuments

Defined in

packages/medusa/src/services/search.ts:72


deleteDocument

deleteDocument(indexName, document_id): Promise<void>

Parameters

NameType
indexNamestring
document_idstring | number

Returns

Promise<void>

Overrides

AbstractSearchService.deleteDocument

Defined in

packages/medusa/src/services/search.ts:63


getIndex

getIndex(indexName): Promise<void>

Parameters

NameType
indexNamestring

Returns

Promise<void>

Overrides

AbstractSearchService.getIndex

Defined in

packages/medusa/src/services/search.ts:37


replaceDocuments

replaceDocuments(indexName, documents, type): Promise<void>

Parameters

NameType
indexNamestring
documentsunknown
typestring

Returns

Promise<void>

Overrides

AbstractSearchService.replaceDocuments

Defined in

packages/medusa/src/services/search.ts:53


search(indexName, query, options): Promise<{ hits: unknown[] }>

Parameters

NameType
indexNamestring
queryunknown
optionsunknown

Returns

Promise<{ hits: unknown[] }>

Overrides

AbstractSearchService.search

Defined in

packages/medusa/src/services/search.ts:78


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

NameType
errRecord<string, unknown> | { code: string }

Returns

boolean

Inherited from

AbstractSearchService.shouldRetryTransaction_

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:31


updateSettings

updateSettings(indexName, settings): Promise<void>

Parameters

NameType
indexNamestring
settingsunknown

Returns

Promise<void>

Overrides

AbstractSearchService.updateSettings

Defined in

packages/medusa/src/services/search.ts:89


withTransaction

withTransaction(transactionManager?): SearchService

Parameters

NameType
transactionManager?EntityManager

Returns

SearchService

Inherited from

AbstractSearchService.withTransaction

Defined in

packages/medusa/src/interfaces/transaction-base-service.ts:14