elastic-dsl-typescript
TypeScript icon, indicating that this package has built-in type declarations

1.8.1 • Public • Published

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

Package Sidebar

Install

npm i elastic-dsl-typescript

Weekly Downloads

105

Version

1.8.1

License

GPL-3.0

Unpacked Size

97.1 kB

Total Files

55

Last publish

Collaborators

  • blynskyniki