Socket
Book a DemoInstallSign in
Socket

@vartoso/kql-to-dsl

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vartoso/kql-to-dsl

Standalone KQL to Elasticsearch DSL converter extracted from Kibana.

0.2.1
latest
Source
npmnpm
Version published
Weekly downloads
13
Maintainers
1
Weekly downloads
 
Created
Source

@vartoso/kql-to-dsl

A standalone KQL (Kibana Query Language) to Elasticsearch DSL converter extracted from Kibana.

Installation

npm install @vartoso/kql-to-dsl

Usage

import { buildEsQuery } from '@vartoso/kql-to-dsl';

// Define your data view (index pattern)
const dataView = {
  title: 'my-index',
  fields: [
    { name: 'status', type: 'string' },
    { name: 'timestamp', type: 'date' },
    { name: 'count', type: 'number' }
  ]
};

// Convert KQL to Elasticsearch DSL
const result = buildEsQuery(
  dataView,
  { query: 'status:"active" AND count > 100', language: 'kuery' },
  [], // filters
  { allowLeadingWildcards: true }
);

console.log(JSON.stringify(result, null, 2));

API

buildEsQuery(dataView, query, filters, config)

Converts a KQL query to Elasticsearch DSL.

Parameters:

  • dataView - Object with title and fields array
  • query - Object with query string and language ('kuery' or 'lucene')
  • filters - Array of filter objects (optional)
  • config - Configuration object (optional)

Returns: Elasticsearch bool query object

Features

  • ✅ KQL to Elasticsearch DSL conversion
  • ✅ Support for field-based queries
  • ✅ Boolean operators (AND, OR, NOT)
  • ✅ Wildcard queries
  • ✅ Range queries
  • ✅ TypeScript support

Changelog

v0.2.0

  • 🎉 Major Fix: Now uses the original Kibana KQL grammar (PEG.js)
  • ✅ Generates proper Elasticsearch DSL with multi_match, bool, and other valid query types
  • ✅ Full compatibility with Kibana's KQL syntax
  • ✅ Production-ready query generation

v0.1.x

  • Initial release with basic KQL parsing

License

MIT

Keywords

kql

FAQs

Package last updated on 26 May 2025

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.