1.11.0 • Published 22 days ago

@codemaskjs/nestjs-elasticsearch v1.11.0

Weekly downloads
-
License
MIT
Repository
github
Last release
22 days ago

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).

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

Adding package to your Nestjs project

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

@Module({
    imports: [
        ElasticsearchModule.register({
            node: 'http://localhost:9200'
        })
    ]
})
class AppModule {}
  1. (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

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

22 days ago

1.9.0

1 month ago

1.10.1

1 month ago

1.10.0

1 month ago

1.8.1

1 month ago

1.8.0

1 month ago

1.7.0

1 month ago

1.6.0

7 months ago

1.5.0

7 months ago

1.4.0

7 months ago

1.3.0

7 months ago