目录

go-querystring-parser

A golang Elasticsearch Querystring parser

Usage

import (
    querystring "github.com/bytedance/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
关于
41.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号