elseql

package module
v0.0.0-...-fbaf806 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 9 Imported by: 0

README

elseql-go

You know, for Query

A SQL-like command line / REPL client for ElasticSearch

SEE ALSO

Documentation

Index

Constants

View Source
const (

	//
	// reserved keywords
	//
	SELECT Keyword = iota
	FACETS
	SCRIPT
	FROM
	WHERE
	FILTER
	EXIST
	MISSING
	ORDER
	BY
	LIMIT
	AFTER
	ASC
	DESC
	AND
	OR
	NOT
	BETWEEN

	NO_KEYWORD Keyword = -1

	//
	// operators
	//
	EQ Operator = iota
	NE
	LT
	LTE
	GT
	GTE
	OP_AND
	OP_OR
	OP_NOT
	IN
	OPENP
	CLOSEP
	STRING_EXPR
	EXISTS_EXPR
	MISSING_EXPR

	NO_OPERATOR Operator = -1
)

Variables

View Source
var (
	Debug = false
)

Functions

func ParseQuery

func ParseQuery(queryString, after string) (jq jmap, index string, columns []string, sErr error)

Parse an ElseSQL query and return an ElasticSearch query object, the index and the list of columns to return

Types

type ElseParser

type ElseParser struct {
	QueryString string // input query string
	// contains filtered or unexported fields
}

func NewParser

func NewParser(queryString string) *ElseParser

func (*ElseParser) Parse

func (p *ElseParser) Parse() (err error)

* Parse ELSEQL statement

func (*ElseParser) Query

func (p *ElseParser) Query() *Query

type ElseSearch

type ElseSearch struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string) *ElseSearch

func (*ElseSearch) AllowInsecure

func (es *ElseSearch) AllowInsecure(insecure bool)

func (*ElseSearch) Search

func (es *ElseSearch) Search(queryString, after, nilValue, index string, returnType ReturnType) (jmap, error)

type Expression

type Expression struct {
	// contains filtered or unexported fields
}

func (*Expression) ExistsExpression

func (e *Expression) ExistsExpression() bool

func (*Expression) GetOperand

func (e *Expression) GetOperand() interface{}

func (*Expression) MissingExpression

func (e *Expression) MissingExpression() bool

func (*Expression) QueryString

func (e *Expression) QueryString() string

* Return a query in Lucene syntax

func (*Expression) String

func (e *Expression) String() string

type Keyword

type Keyword int

func FindKeyword

func FindKeyword(ks string) (k Keyword, ok bool)

func (Keyword) Lower

func (k Keyword) Lower() string

func (Keyword) String

func (k Keyword) String() string

type NameValue

type NameValue struct {
	Name  string
	Value interface{}
}

func (NameValue) List

func (nv NameValue) List(sep string) (n, v string)

func (NameValue) QueryString

func (nv NameValue) QueryString() string

func (NameValue) String

func (nv NameValue) String() string

func (NameValue) Strings

func (nv NameValue) Strings() (n, v string)

type Operator

type Operator int

func (Operator) String

func (op Operator) String() string

type ParseError

type ParseError string

* Parse error

func (ParseError) Error

func (e ParseError) Error() string

type Query

type Query struct {
	SelectList []string
	FacetList  []string

	Index      string
	WhereExpr  *Expression
	FilterExpr *Expression

	Script    *NameValue
	OrderList []NameValue

	From  int
	Size  int
	After string
}

* This is the output of a parsed statement

func (*Query) String

func (q *Query) String() string

type ReturnType

type ReturnType int
const (
	Full ReturnType = iota
	Data
	List
	StringList
)

type SearchError

type SearchError struct {
	Err   error
	Query string
}

func (SearchError) Error

func (e SearchError) Error() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL