Socket
Socket
Sign inDemoInstall

elastic-dsl-typescript

Package Overview
Dependencies
0
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    elastic-dsl-typescript

Node.js ElasticSearch search query builder


Version published
Weekly downloads
113
increased by41.25%
Maintainers
1
Install size
94.8 kB
Created
Weekly downloads
 

Readme

Source

NPM

Library for generating queries (Elastic DSL) in the typescript language.

Support :
  • nested
  • script_fields
  • bool
  • query
  • aggregations
  • aggregations (ACTIVE\PASSIVE facet patern)

Generating hints based on types : type Based on the selected, the context of the prompts changes : bool_type After selecting the filter type, it shows options for a specific range_opts


range_params


Not all fields are currently implemented. But you can extend the support yourself in your code.*** range_params

Advanced exapmles in tests directory

example:
import { Bool, Query } from '../../index';

const q = new Query()
  .addProps('_source', ['field'])
  .addProps('explain', true)
  .addProps('from', 0)
  .addProps('size', 100)
  .addProps('q', 'Lucene query string ')
  .addQuery('match', {
    message: {
      query: 'query',
    },
  })
  .addQuery('term', {
    field: 'f',
    value: 'term',
  })
  .addQuery('range', {
    gt: 0,
    gte: 0,
  });

q.bool.addBuilder(
  'must',
  new Bool().add('must', 'term', {
    field: 'articul',
    params: {
      value: '111',
    },
  }),
);
result :
{
  "_source": ["field"],
  "explain": true,
  "from": 0,
  "q": "Lucene query string ",
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "must": [
              {
                "term": {
                  "articul": {
                    "value": "111"
                  }
                }
              }
            ]
          }
        }
      ]
    },
    "match": {
      "message": {
        "query": "query"
      }
    },
    "range": {
      "gt": 0,
      "gte": 0
    },
    "term": {
      "field": "f",
      "value": "term"
    }
  },
  "size": 100
}
TEST
npm run test

Keywords

FAQs

Last updated on 23 May 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc