You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@codemaskjs/nestjs-elasticsearch

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemaskjs/nestjs-elasticsearch

Nestjs Elasticsearch Module

1.11.0
latest
Source
npmnpm
Version published
Weekly downloads
1
-96.15%
Maintainers
1
Weekly downloads
 
Created
Source

Nestjs Elasticsearch Module

[!NOTE]
This repository is a Work In Progress, driven by the motive.

Motive

Due to Production Experience when working with Elasticsearch leaded to maintenance issues when extensively used searches, filters and aggregations (especially aggregations).

  • Current Elasticsearch Nestjs Modules does not provide auto-complete for queries
  • Since Elasticsearch indexes are schema-less we got no proper feedback about what we should expect on the index
  • Elasticsearch response forgets about types of aggregations

Adding package to your Nestjs project

  • Install package using yarn or npm
$ yarn add @codemaskjs/nestjs-elasticsearch
// or
$ npm -i @codemaskjs/nestjs-elasticsearch
  • Import module
import { ElasticsearchModule } from '@codemaskjs/nestjs-elasticsearch'

@Module({
    imports: [
        ElasticsearchModule.register({
            node: 'http://localhost:9200'
        })
    ]
})
class AppModule {}
  • (optional) Registering Index with Document
import { RegisterIndex } from '@codemaskjs/nestjs-elasticsearch'

@RegisterIndex('examples')
export class ExampleDocument {
    readonly id: string
    readonly test?: string
}
import { Injectable } from '@nestjs/common'
import { Index } from '@codemaskjs/nestjs-elasticsearch'
import { ExampleDocument } from './example.document'

@Injectable()
export class ExampleService {
    @InjectIndex(ExampleDocument)
    private readonly exampleIndex: Index<ExampleDocument>

    getExampleDocuments() {
        return this.exampleIndex.search()
    }
}
import { ElasticsearchModule } from '@codemaskjs/nestjs-elasticsearch'
import { ExampleDocument } from './example.document'

@Module({
    imports: [
        providers: [ExampleService],
        ElasticsearchModule.register({
            node: 'http://localhost:9200'
        }),
        ElasticsearchModule.forFeature([
            ExampleDocument
        ])
    ]
})
class AppModule {}

Future actions

  • Add case_insensitive option to term search
  • Filter undefined/null values from request body
  • Add field to aggregations body so that it can return more than default 10 results
  • Add and <search_after> fields to request type and field to response type to enable pagination
  • Add e2e tests setup for features scenario tests
  • Add extraction of aggregations on response
  • Add healthcheck from ElasticsearchService
  • Add checkDocumentIntegrity with the connection on the source on runtime
  • Add optional script to sum, avg, max aggregation
  • Add order field to terms aggregation

Keywords

nestjs

FAQs

Package last updated on 17 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts