'What data is needed to connect Elasticsearch module to Nestjs?
I have a problem that when running a project on nestjs and elastic an error is displayed
nestjs_api_dev | ConfigurationError: Missing node(s) option
nestjs_api_dev | at new Client (/usr/src/app/node_modules/@elastic/elasticsearch/index.js:78:13)
nestjs_api_dev | at new ElasticsearchService (/usr/src/app/node_modules/@nestjs/elasticsearch/dist/elasticsearch.service.js:21:9)
nestjs_api_dev | at Injector.instantiateClass (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:301:19)
nestjs_api_dev | at callback (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:48:41)
nestjs_api_dev | at Injector.resolveConstructorParams (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:124:24)
nestjs_api_dev | at Injector.loadInstance (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:52:9)
nestjs_api_dev | at Injector.loadProvider (/usr/src/app/node_modules/@nestjs/core/injector/injector.js:74:9)
nestjs_api_dev | at async Promise.all (index 3)
nestjs_api_dev | at InstanceLoader.createInstancesOfProviders (/usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:44:9)
nestjs_api_dev | at /usr/src/app/node_modules/@nestjs/core/injector/instance-loader.js:29:13
In this case, everything was done according to the documentation for @nestjs/elasticsearch Here is my code for connecting elasticsearch to the project:
import { Module } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { ElasticsearchModule } from "@nestjs/elasticsearch";
@Module({
imports: [
ConfigModule,
ElasticsearchModule.registerAsync({
imports: [ConfigModule],
useFactory: async (configService: ConfigService) => ({
node: "http://localhost:9200", // need use configService
auth: {
username: "elastic",
password: "changeme",
},
}),
inject: [ConfigService],
}),
],
exports: [ElasticsearchModule],
})
export class SearchModule {}
Link to documentation @nestjs/elasticsearch on npm: @nestjs/elasticsearch
Please tell me what am I doing wrong
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|