ndjson-query-language is a Newline delimited JSON (NDJSON) command-line interface and library for developers.
Use MongoDB-like pipelines to query your log files.
Usage
npm install --global ndjson-query-language
ndjson-query-language --file data.ndjson --output output.ndjson --pipelines pipelines.json
Sample Files
See Sample Files Here
Operators
{ "age": 20, "fullName": "Foo Bar" }
{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }
$contains
{
"$match": {
"fullName": { "$contains": "Doe" }
}
}
Returns:
{ "age": 80, "fullName": "John Doe" }
$eq
Specifies equality condition. The $eq operator matches documents where the value of a field equals the specified value.
{
"$match": {
"fullName": { "$eq": "John Doe" }
}
}
Returns:
{ "age": 80, "fullName": "John Doe" }
$exists
When is true, $exists matches the documents that contain the field, including documents where the field value is null. If is false, the query returns only the documents that do not contain the field.
{
"$match": {
"fullName": { "$exists": true }
}
}
Returns:
{ "age": 20, "fullName": "Foo Bar" }
{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }
$gt
$gt selects those documents where the value of the field is greater than (i.e. >) the specified value.
{
"$match": {
"age": { "$gt": 30 }
}
}
Returns:
{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }
$gte
$gte selects the documents where the value of the field is greater than or equal to (i.e. >=) a specified value (e.g. value.)
{
"$match": {
"age": { "$gte": 30 }
}
}
Returns:
{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }
$lt
$lt selects the documents where the value of the field is less than (i.e. <) the specified value.
{
"$match": {
"age": { "$lt": 30 }
}
}
Returns:
{ "age": 20, "fullName": "Foo Bar" }
$lte
$lte selects the documents where the value of the field is less than or equal to (i.e. <=) the specified value.
{
"$match": {
"age": { "$lte": 30 }
}
}
Returns:
{ "age": 20, "fullName": "Foo Bar" }
$ne
$ne selects the documents where the value of the field is not equal to the specified value. This includes documents that do not contain the field.
{
"$match": {
"fullName": { "$ne": "John Doe" }
}
}
Returns:
{ "age": 40, "fullName": "Hello World" }
{ "age": 80, "fullName": "John Doe" }
License
ndjson-query-language is open-source software distributed under the terms of the MIT license.