{"id":14978591,"url":"https://github.com/nestjs/elasticsearch","last_synced_at":"2025-04-08T09:09:49.021Z","repository":{"id":37291048,"uuid":"138471273","full_name":"nestjs/elasticsearch","owner":"nestjs","description":"Elasticsearch module based on the official elasticsearch package 🌿","archived":false,"fork":false,"pushed_at":"2024-10-29T14:11:52.000Z","size":3372,"stargazers_count":384,"open_issues_count":2,"forks_count":51,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-29T14:58:34.121Z","etag":null,"topics":["elasticsearch","nest","nestjs","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://nestjs.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nestjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-24T10:01:20.000Z","updated_at":"2024-10-29T07:06:00.000Z","dependencies_parsed_at":"2024-01-31T00:28:56.072Z","dependency_job_id":"2807bf0b-8686-48c8-8acb-4ab6a41abac5","html_url":"https://github.com/nestjs/elasticsearch","commit_stats":{"total_commits":1404,"total_committers":16,"mean_commits":87.75,"dds":0.4337606837606838,"last_synced_commit":"8aef8323a35bb815888724d2779f30f04d6f06b1"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Felasticsearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Felasticsearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Felasticsearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nestjs%2Felasticsearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nestjs","download_url":"https://codeload.github.com/nestjs/elasticsearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299829,"owners_count":20916190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elasticsearch","nest","nestjs","nodejs","typescript"],"created_at":"2024-09-24T13:57:58.811Z","updated_at":"2025-04-08T09:09:48.978Z","avatar_url":"https://github.com/nestjs.png","language":"TypeScript","funding_links":["https://opencollective.com/nest","https://paypal.me/kamilmysliwiec"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://nestjs.com/\" target=\"blank\"\u003e\u003cimg src=\"https://nestjs.com/img/logo-small.svg\" width=\"120\" alt=\"Nest Logo\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n[travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master\n[travis-url]: https://travis-ci.org/nestjs/nest\n[linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux\n[linux-url]: https://travis-ci.org/nestjs/nest\n\n  \u003cp align=\"center\"\u003eA progressive \u003ca href=\"http://nodejs.org\" target=\"blank\"\u003eNode.js\u003c/a\u003e framework for building efficient and scalable server-side applications.\u003c/p\u003e\n    \u003cp align=\"center\"\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@nestjs/core.svg\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/@nestjs/core.svg\" alt=\"Package License\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/~nestjscore\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/@nestjs/core.svg\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://discord.gg/G7Qnnhy\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/badge/discord-online-brightgreen.svg\" alt=\"Discord\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#backer\"\u003e\u003cimg src=\"https://opencollective.com/nest/backers/badge.svg\" alt=\"Backers on Open Collective\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://opencollective.com/nest#sponsor\"\u003e\u003cimg src=\"https://opencollective.com/nest/sponsors/badge.svg\" alt=\"Sponsors on Open Collective\" /\u003e\u003c/a\u003e\n  \u003ca href=\"https://paypal.me/kamilmysliwiec\"\u003e\u003cimg src=\"https://img.shields.io/badge/Donate-PayPal-dc3d53.svg\"/\u003e\u003c/a\u003e\n  \u003ca href=\"https://twitter.com/nestframework\"\u003e\u003cimg src=\"https://img.shields.io/twitter/follow/nestframework.svg?style=social\u0026label=Follow\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n  \u003c!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)\n  [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)--\u003e\n\n## Description\n\nElasticsearch module for [Nest](https://github.com/nestjs/nest) based on the official [@elastic/elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) package.\n\n## Installation\n\n```bash\n$ npm i --save @nestjs/elasticsearch @elastic/elasticsearch\n```\n\n## Usage\n\nImport `ElasticsearchModule`:\n\n```typescript\n@Module({\n  imports: [ElasticsearchModule.register({\n    node: 'http://localhost:9200',\n  })],\n  providers: [...],\n})\nexport class SearchModule {}\n```\n\nInject `ElasticsearchService`:\n\n```typescript\n@Injectable()\nexport class SearchService {\n  constructor(private readonly elasticsearchService: ElasticsearchService) {}\n}\n```\n\n## Async options\n\nQuite often you might want to asynchronously pass your module options instead of passing them beforehand. In such case, use `registerAsync()` method, that provides a couple of various ways to deal with async data.\n\n**1. Use factory**\n\n```typescript\nElasticsearchModule.registerAsync({\n  useFactory: () =\u003e ({\n    node: 'http://localhost:9200'\n  })\n});\n```\n\nObviously, our factory behaves like every other one (might be `async` and is able to inject dependencies through `inject`).\n\n```typescript\nElasticsearchModule.registerAsync({\n  imports: [ConfigModule],\n  useFactory: async (configService: ConfigService) =\u003e ({\n    node: configService.get('ELASTICSEARCH_NODE'),\n  }),\n  inject: [ConfigService],\n}),\n```\n\n**2. Use class**\n\n```typescript\nElasticsearchModule.registerAsync({\n  useClass: ElasticsearchConfigService\n});\n```\n\nAbove construction will instantiate `ElasticsearchConfigService` inside `ElasticsearchModule` and will leverage it to create options object.\n\n```typescript\nclass ElasticsearchConfigService implements ElasticsearchOptionsFactory {\n  createElasticsearchOptions(): ElasticsearchModuleOptions {\n    return {\n      node: 'http://localhost:9200'\n    };\n  }\n}\n```\n\n**3. Use existing**\n\n```typescript\nElasticsearchModule.registerAsync({\n  imports: [ConfigModule],\n  useExisting: ConfigService,\n}),\n```\n\nIt works the same as `useClass` with one critical difference - `ElasticsearchModule` will lookup imported modules to reuse already created `ConfigService`, instead of instantiating it on its own.\n\n## API Spec\n\nThe `ElasticsearchService` wraps the `Client` from the official [@elastic/elasticsearch](https://www.npmjs.com/package/@elastic/elasticsearch) methods. The `ElasticsearchModule.register()` takes `options` object as an argument, [read more](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-configuration.html).\n\n## Support\n\nNest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).\n\n## Stay in touch\n\n- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)\n- Website - [https://nestjs.com](https://nestjs.com/)\n- Twitter - [@nestframework](https://twitter.com/nestframework)\n\n## License\n\nNest is [MIT licensed](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjs%2Felasticsearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnestjs%2Felasticsearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnestjs%2Felasticsearch/lists"}