Skip to content

ConvergenceFinance/elasticsearch-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ElasticSearch Builder

A TypeScript builder for ElasticSearch (search body, index creation, etc.).

⚠️ IN DEVELOPMENT, DO NOT USE IN PRODUCTION ⚠️

This project currently does not support all versions of ElasticSearch or contain all the possible variables for building a complete and valid ES JSON output.

Installation

npm i @convergence-finance/elasticsearch-builder

Examples

Search Query Body

import ElasticSearchBuilder from "@convergence-finance/elasticsearch-builder"

const searchBody = ElasticSearchBuilder.instance()
    .buildSearchBody()
    .query()
        .bool()
            .mustNot()
                .match("isActive", true)
            .end()
            .mustNot()
                .match("status", 10)
            .end()
        .end()
    .end()
    .build()

Output of searchBody:

{
    "query": {
        "bool": {
            "must_not": [
                {
                    "match": {
                        "isActive": true
                    }
                },
                {
                    "match": {
                        "status": 10
                    }
                }
            ]
        }
    }
}

Tests

npm run test

License

This project is open-sourced software licensed under the MIT license.

About

A TypeScript builder for ElasticSearch (search body, index creation, etc.)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •