πŸš€ DAY 2 OF LAUNCH WEEK: Unify Your Security Stack with Socket Basics.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

dsl-builder-test

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsl-builder-test

OpenSearch Query Builder - Extract from OpenSearch Dashboards

latest
npmnpm
Version
1.0.6
Version published
Maintainers
1
Created
Source

OpenSearch Query Builder

A library extracted from OpenSearch Dashboard for Query DSL conversion. This package provides core functionality for OpenSearch/Elasticsearch query builder.

πŸ“¦ Installation

npm install dsl-builder
yarn add dsl-builder

πŸš€ Key Features

Query DSL Conversion

  • KQL (Kibana Query Language) parsing and conversion
  • Filter query creation and management
  • OpenSearch/Elasticsearch query DSL generation

Field Type System

  • Support for various field types (string, number, date, geo, etc.)
  • Specialized query processing for each field type

πŸ“– Usage

KQL Query Conversion

import { buildOpenSearchQuery } from 'dsl-builder';

const indexPattern = {
  title: 'logs-*',
  fields: [
    { name: 'status', type: 'string' },
    { name: 'response_time', type: 'number' },
    { name: '@timestamp', type: 'date' }
  ]
};

// Convert KQL query to OpenSearch DSL
const dsl = buildOpenSearchQuery(indexPattern, [
  {
    query: 'status:error AND response_time:>500',
    language: 'kuery'
  }
]);

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

πŸ”§ API Reference

buildOpenSearchQuery

Converts query objects to OpenSearch DSL.

function buildOpenSearchQuery(
  indexPattern: IndexPattern,
  queries: Query[],
  filters: Filter[] = [],
  config: QueryState = {}
): OpenSearchQuery

πŸ“ Project Structure

src/
β”œβ”€β”€ index_patterns/          # Index pattern related functionality
β”‚   β”œβ”€β”€ fields/             # Field types and mapping
β”‚   β”œβ”€β”€ index_patterns/     # Index pattern service
β”‚   β”œβ”€β”€ lib/               # Utility library
β”‚   └── errors/            # Error handling
β”œβ”€β”€ opensearch_query/       # Query DSL conversion
β”‚   β”œβ”€β”€ kuery/             # KQL parser and converter
β”‚   β”œβ”€β”€ filters/           # Filter processing
β”‚   └── opensearch_query/  # Main query builder
β”œβ”€β”€ query/                 # Query types and interfaces
β”œβ”€β”€ osd_field_types/       # Field type system
└── utils/                 # Common utilities

πŸ§ͺ Testing

# Run tests
npm test

# Test watch mode
npm run test:watch

πŸ“¦ Build

# TypeScript compilation
npm run build

# Prepare for deployment
npm run prepare

🀝 Contributing

This project was extracted from the src/plugins/data/common/index_patterns module of OpenSearch Dashboard.

πŸ“„ License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

πŸ™ Acknowledgments

This library was extracted from the OpenSearch Dashboard project. Thanks to the OpenSearch community.

Keywords

opensearch

FAQs

Package last updated on 03 Jul 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