Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

sudo-suhas/elastic-marshal

Repository files navigation

elastic-marshal Build Status

Helper library for [un]marshalling elastic-builder objects

Install

$ npm install elastic-marshal

Usage

'use strict';

const util = require('util');
const bob = require('elastic-builder');
const marshaller = require('elastic-marshal');

const qry = bob.boolQuery()
    .must(bob.termQuery('user', 'kimchy'))
    .must(bob.rangeQuery('age').gte(10).lte(20))
    .must(
        bob.boolQuery().should([
            bob.termQuery('tag', 'wow'),
            bob.termQuery('tag', 'elasticsearch')
        ])
    );

const qryStr = marshaller.marshal(qry);

console.log('Marshalled string -', qryStr);

const unmarshalled = marshaller.unmarshal(qryStr);

console.log('Unmarshalled object -', util.inspect(unmarshalled, true, 7, true));

The module uses elastic-builder and serialijse for serialisation and deserialisation of elastic-builder query objects.

Related

License

MIT © Suhas Karanth