query

package
v1.7.0-dev-20191004 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2019 License: Apache-2.0 Imports: 2 Imported by: 2

Documentation

Overview

Package query contains helpful code for building structured search queries. The contents of this package are about making the query logic easier to read, by providing helpers for building the underlying search proto buffer expressions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is the type used to allow fluent construction of search queries.

func Bool

func Bool(value bool) Builder

Bool builds a boolean literal search expression.

func Double

func Double(value float64) Builder

Double builds an floating point literal search expression.

func Expression

func Expression(e *search.Expression) Builder

Expression creates a builder from a search expression.

func Name

func Name(name string) Builder

Name builds a root name lookup search expression.

func Not

func Not(rhs Builder) Builder

Not builds a search expression that applies a boolean not to the supplied rhs.

func Signed

func Signed(value int64) Builder

Signed builds a signed integer literal search expression.

func String

func String(value string) Builder

String builds a string literal search expression.

func Unsigned

func Unsigned(value uint64) Builder

Unsigned builds an unsigned integer literal search expression.

func Value

func Value(value interface{}) Builder

Value creates a builder from a value. The type of expression will be inferred from the type of the value.

func (Builder) And

func (lhs Builder) And(rhs Builder) Builder

And builds a search expression that is the "and" of the lhs and rhs.

func (Builder) Equal

func (lhs Builder) Equal(rhs Builder) Builder

Equal builds a search expression that compares the lhs and rhs for equality.

func (Builder) Expression

func (b Builder) Expression() *search.Expression

Expression returns the content of the builder as a search expression.

func (Builder) Greater

func (lhs Builder) Greater(rhs Builder) Builder

Greater builds a search expression that tests whether the lhs is greater than the rhs.

func (Builder) GreaterOrEqual

func (lhs Builder) GreaterOrEqual(rhs Builder) Builder

GreaterOrEqual builds a search expression that tests whether the lhs is greater than or equal to the rhs.

func (Builder) Less

func (lhs Builder) Less(rhs Builder) Builder

Less builds a search expression that tests whether the lhs is less than the rhs.

func (Builder) LessOrEqual

func (lhs Builder) LessOrEqual(rhs Builder) Builder

LessOrEqual builds a search expression that tests whether the lhs is less than or equal to the rhs.

func (Builder) Member

func (object Builder) Member(name string) Builder

Member builds a search expression that looks up the named member of the object.

func (Builder) Or

func (lhs Builder) Or(rhs Builder) Builder

Or builds a search expression that is the "or" of the lhs and rhs.

func (Builder) Query

func (b Builder) Query() *search.Query

Query returns the content of the builder as a completed search query.

func (Builder) Regex

func (value Builder) Regex(pattern string) Builder

Regex builds a search expression that tests whether value matches the supplied regex pattern.

func (Builder) Replace

func (b Builder) Replace(match Builder, expr Builder) Builder

Replace substitues expr for match in the expression tree.

func (Builder) Set

func (b Builder) Set(name string, value interface{}) Builder

Set is a small helper on top of Replace for the common case of identifier substitution. name is a top level identifier to replace, and Value(value) is the expression to replace it with.

func (Builder) Subscript

func (value Builder) Subscript(key Builder) Builder

Subscript builds a search expression that applies the key as a subscript to the value.

func (Builder) Using

func (b Builder) Using(name string) func(interface{}) Builder

Using returns a function that when invoked returns a copy of b with Name(name) replace by Value(value). This is to make the common case of single value substitutions into precompiles queries easy. To use it

var myQuery = script.MustCompile("Object.Name == $V").Using("$V")
myService.Search(myQuery(nameToFind).Query())

Jump to

Keyboard shortcuts

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