2.0.4 • Published 5 years ago

elasticsearch-dsl-types v2.0.4

Weekly downloads
424
License
MIT
Repository
github
Last release
5 years ago

elasticsearch-dsl

Write type-safe Elasticsearch queries for TypeScript

Installation

npm install elasticsearch-dsl-types --save-dev

Examples

Secure queries with DSL.Query:

import { DSL } from 'elasticsearch-dsl-types';

interface Properties {
    hello: string;
    world: number;
}

const q0: DSL.Term<Properties> = {
    'term': {
        'hello': 'world',
    }
};

const q1: DSL.Query<Properties> = {
    bool: {
        must: q0,
        must_not: [q0, {'term': {'hello': 'world'}}],
    },
}

const q2: DSL.GeoShape<keyof Properties> = {
    'geo_shape': {
        'hello': {
            'shape': { 'type': 'Point' },
            'relation': 'within'
        },
    }
};

const q3: DSL.Bool = {
    'bool': {
        'must': {
            'term': {
                'hello': 'hello',
            },
        },
        'should': [q2, q2],
        'must_not': [
            { 'terms': { 'world': [1, 2, 3] } },
        ]
    },
};

Development

Set up:

npm install

Build and watch:

npx tsc --watch

Run tests:

npm test
2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago