Categorygithub.com/Group-IB/go-querystring-parser
modulepackage
1.0.2
Repository: https://github.com/group-ib/go-querystring-parser.git
Documentation: pkg.go.dev

# README

go-querystring-parser

A golang Elasticsearch Querystring parser

Usage

import (
    querystring "https://github.com/Group-IB/go-querystring-parser"
)

Then use:

query := "message: test\\ value AND datetime: [\"2020-01-01T00:00:00\" TO \"2020-12-31T00:00:00\"]"
ast, err := querystring.Parse(query)
if err != nil {
    // error handling
}

// do something with ast

The AST parsed from above querystring:

// print via github.com/davecgh/go-spew.Dump
(*querystring.AndCondition)(0xc00000c200)({
    Left: (*querystring.MatchCondition)(0xc00000c1e0)({
        Field: (string) (len=7) "message",
        Value: (string) (len=10) "test value"
    }),
    Right: (*querystring.TimeRangeCondition)(0xc000076750)({
        Field: (string) (len=8) "datetime",
        Start: (*string)(0xc0000545b0)((len=19) "2020-01-01T00:00:00"),
        End: (*string)(0xc0000545c0)((len=19) "2020-12-31T00:00:00"),
        IncludeStart: (bool) true,
        IncludeEnd: (bool) true
    })
})

For Developers

After edit querystring.y, gen code via run:

go generate

# Functions

MustNewNumberRangeCondition panics and must be used only inside goyacc, due it recovers panics into goyacc errors.
MustNewRegexpCondition panics and must be used only inside goyacc, due it recovers panics into goyacc errors.
MustNewWildcardCondition panics and must be used only inside goyacc, due it recovers panics into goyacc errors.
NewAndCondition .
NewMatchCondition .
NewNotCondition .
NewOrCondition .
NewRegexpCondition .
NewTimeRangeCondition .
NewWildcardCondition .
Parse querystring and return Condition.
No description provided by the author

# Structs

AndCondition .
MatchCondition .
NotCondition .
NumberRangeCondition .
No description provided by the author
OrCondition .
RegexpCondition .
TimeRangeCondition .
WildcardCondition .

# Interfaces

Condition .
No description provided by the author
FieldableCondition .

# Type aliases

No description provided by the author