es2gen

package
v0.0.0-...-fc2d520 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MatchAll = &matchall{&struct{}{}}

MatchAll maps to the Elasticsearch "match_all" filter

View Source
var MatchNone = NotFilter(MatchAll)

MatchNone matches no documents.

View Source
var (
	// MaxDepth specifies the depth at which we are certain the filter generator is in an endless loop
	// This *shouldn't* happen, but is better than a stack overflow
	MaxDepth = 1000
)

Functions

func DayBucket

func DayBucket(dt time.Time) int

copy-pasta from entity to avoid the import when we actually parameterize this we will need to do it differently anyway

func Exists

func Exists(field *gentypes.FieldType) interface{}

Exists creates a new Elasticsearch filter {"exists": {"field": field}}

func In

func In(field *gentypes.FieldType, values []interface{}) interface{}

In creates a new Elasticsearch terms filter {"terms": {field: values}}

func Nested

func Nested(field *gentypes.FieldType, filter interface{}) *nested

In creates a new Elasticsearch nested filter

{ "nested": {
     "filter": {"and":[
              {"term": { "k":fieldName}},
              filter,
     ]} ,
     "path":"path_to_obj"
 }}

func Term

func Term(fieldName string, value interface{}) *term

Term creates a new Elasticsearch term filter {"term": {field: value}}

func Wildcard

func Wildcard(field, value string) *wildcardquery

Wilcard creates a new Elasticserach wildcard query

{"query": {"wildcard": {field: value}}}

nested

{"nested": {
   "filter" : { "and" : [
           {"query": {"wildcard": {"v": value}}},
           {"term":{"k": field_key}}
   "path": path
  }
}

Types

type BoolFilter

type BoolFilter struct {
	Occurs         BoolOccurrence `json:"bool"`
	MinShouldMatch int            `json:"minimum_should_match,omitempty"`
}

func AndFilter

func AndFilter(v []interface{}) *BoolFilter

func NotFilter

func NotFilter(v interface{}) *BoolFilter

func OrFilter

func OrFilter(v []interface{}) *BoolFilter

type BoolOccurrence

type BoolOccurrence struct {
	Filter  []interface{} `json:"filter,omitempty"`
	Should  []interface{} `json:"should,omitempty"`
	MustNot interface{}   `json:"must_not,omitempty"`
}

type FilterGenerator

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

func (*FilterGenerator) Walk

type NestedFilter

type NestedFilter struct {
	Filter interface{} `json:"filter"`
	Path   string      `json:"path"`
}

type RangeFilter

type RangeFilter struct {
	Range map[string]RangeQry `json:"range"`
}

type RangeQry

type RangeQry struct {
	GTE interface{} `json:"gte,omitempty"`
	LTE interface{} `json:"lte,omitempty"`
	GT  interface{} `json:"gt,omitempty"`
	LT  interface{} `json:"lt,omitempty"`
}

Jump to

Keyboard shortcuts

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