cqr

package module
v0.0.0-...-345896d Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: MIT Imports: 4 Imported by: 24

README

cqr

GoDoc Go Report Card gocover

Common query representation for keyword and Boolean queries in Go

This package provides a common standard for query representation in Go. Both the transmute and lexes query parsers are compatible with Common Query Representation. A set of tools for query analysis to come.

Documentation

Overview

Package cqr provides a common query representation for keyword and Boolean queries in go.

Index

Constants

This section is empty.

Variables

View Source
var (
	ExplodedString  = "exploded"
	TruncatedString = "truncated"
	AND             = "and"
	OR              = "or"
	NOT             = "not"
)

Functions

func IsBoolean

func IsBoolean(query CommonQueryRepresentation) bool

Types

type BooleanQuery

type BooleanQuery struct {
	Operator string                      `json:"operator"`
	Children []CommonQueryRepresentation `json:"children"`
	Options  map[string]interface{}      `json:"options"`
}

BooleanQuery is a nested set of queries, containing either more Boolean queries, or keywords.

func NewBooleanQuery

func NewBooleanQuery(operator string, children []CommonQueryRepresentation) BooleanQuery

NewBooleanQuery constructs a new Boolean query.

func (BooleanQuery) GetOption

func (b BooleanQuery) GetOption(key string) interface{}

GetOption gets an optional parameter of the Boolean Query.

func (BooleanQuery) SetOption

func (b BooleanQuery) SetOption(key string, value interface{}) CommonQueryRepresentation

SetOption sets an optional parameter on the Boolean query.

func (BooleanQuery) String

func (b BooleanQuery) String() (s string)

String computes the string representation of a Boolean query.

func (BooleanQuery) StringPretty

func (b BooleanQuery) StringPretty() (s string)

String computes the string representation of a Boolean query.

type CommonQueryRepresentation

type CommonQueryRepresentation interface {
	String() string
	StringPretty() string
	GetOption(string) interface{}
	SetOption(string, interface{}) CommonQueryRepresentation
}

CommonQueryRepresentation is the parent type for all subtypes.

type Keyword

type Keyword struct {
	QueryString string                 `json:"query"`
	Fields      []string               `json:"fields"`
	Options     map[string]interface{} `json:"options"`
}

Keyword is a single query expression.

func CopyKeyword

func CopyKeyword(query Keyword) Keyword

func NewKeyword

func NewKeyword(queryString string, fields ...string) Keyword

NewKeyword constructs a new keyword.

func (Keyword) GetOption

func (k Keyword) GetOption(key string) interface{}

GetOption gets an optional parameter of the keyword.

func (Keyword) SetOption

func (k Keyword) SetOption(key string, value interface{}) CommonQueryRepresentation

SetOption sets an optional parameter on the keyword.

func (Keyword) String

func (k Keyword) String() string

String computes the string representation of a keyword.

func (Keyword) StringPretty

func (k Keyword) StringPretty() string

Jump to

Keyboard shortcuts

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