Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveNumericPaddedTerms

func RemoveNumericPaddedTerms(sourceValues [][]byte) [][]byte

Types

type Aggregation

type Aggregation interface {
	Fields() []string
	Calculator() Calculator
}

type Aggregations

type Aggregations map[string]Aggregation

func (Aggregations) Add

func (a Aggregations) Add(name string, aggregation Aggregation)

func (Aggregations) Fields

func (a Aggregations) Fields() []string

type Bucket

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

func NewBucket

func NewBucket(name string, aggregations map[string]Aggregation) *Bucket

func (*Bucket) Aggregation

func (b *Bucket) Aggregation(name string) Calculator

func (*Bucket) Aggregations

func (b *Bucket) Aggregations() map[string]Calculator

func (*Bucket) Buckets

func (b *Bucket) Buckets(name string) []*Bucket

func (*Bucket) Consume

func (b *Bucket) Consume(d *DocumentMatch)

func (*Bucket) Count

func (b *Bucket) Count() uint64

func (*Bucket) Duration

func (b *Bucket) Duration() time.Duration

func (*Bucket) Finish

func (b *Bucket) Finish()

func (*Bucket) Merge

func (b *Bucket) Merge(other *Bucket)

func (*Bucket) Metric

func (b *Bucket) Metric(name string) float64

func (*Bucket) Name

func (b *Bucket) Name() string

type BucketCalculator

type BucketCalculator interface {
	Calculator
	Buckets() []*Bucket
}

type Calculator

type Calculator interface {
	Consume(*DocumentMatch)
	Finish()
	Merge(Calculator)
}

type Collectible

type Collectible interface {
	Next(ctx *Context) (*DocumentMatch, error)
	DocumentMatchPoolSize() int
	Close() error
}

type Collector

type Collector interface {
	Collect(context.Context, Aggregations, Collectible) (DocumentMatchIterator, error)

	Size() int
	BackingSize() int
}

type CompositeScorer

type CompositeScorer interface {
	ScoreComposite(constituents []*DocumentMatch) float64
	ExplainComposite(constituents []*DocumentMatch) *Explanation
}

type ConstantGeoPointSource

type ConstantGeoPointSource geo.Point

func NewConstantGeoPointSource

func NewConstantGeoPointSource(p geo.Point) *ConstantGeoPointSource

func (*ConstantGeoPointSource) Fields

func (p *ConstantGeoPointSource) Fields() []string

func (*ConstantGeoPointSource) GeoPoint

func (p *ConstantGeoPointSource) GeoPoint(_ *DocumentMatch) *geo.Point

type ConstantTextValueSource

type ConstantTextValueSource []byte

func (ConstantTextValueSource) Fields

func (c ConstantTextValueSource) Fields() []string

func (ConstantTextValueSource) Value

func (c ConstantTextValueSource) Value(_ *DocumentMatch) []byte

type Context

type Context struct {
	DocumentMatchPool *DocumentMatchPool
	// contains filtered or unexported fields
}

Context represents the context around a single search

func NewSearchContext

func NewSearchContext(size, sortSize int) *Context

func (*Context) DocValueReaderForReader

func (sc *Context) DocValueReaderForReader(r DocumentValueReadable, fields []string) (segment.DocumentValueReader, error)

func (*Context) Size

func (sc *Context) Size() int

type DateValueSource

type DateValueSource interface {
	Fields() []string
	Date(match *DocumentMatch) time.Time
}

type DateValuesSource

type DateValuesSource interface {
	Fields() []string
	Dates(match *DocumentMatch) []time.Time
}

type DocumentMatch

type DocumentMatch struct {
	Number      uint64
	Score       float64
	Explanation *Explanation
	Locations   FieldTermLocationMap
	SortValue   [][]byte

	// used to maintain natural index order
	HitNumber int

	// used to temporarily hold field term location information during
	// search processing in an efficient, recycle-friendly manner, to
	// be later incorporated into the Locations map when search
	// results are completed
	FieldTermLocations []FieldTermLocation
	// contains filtered or unexported fields
}

func (*DocumentMatch) Complete

func (dm *DocumentMatch) Complete(prealloc []Location) []Location

Complete performs final preparation & transformation of the DocumentMatch at the end of search processing, also allowing the caller to provide an optional preallocated locations slice

func (*DocumentMatch) DocValues

func (dm *DocumentMatch) DocValues(field string) [][]byte

func (*DocumentMatch) LoadDocumentValues

func (dm *DocumentMatch) LoadDocumentValues(ctx *Context, fields []string) error

func (*DocumentMatch) Reset

func (dm *DocumentMatch) Reset() *DocumentMatch

Reset allows an already allocated DocumentMatch to be reused

func (*DocumentMatch) SetReader

func (dm *DocumentMatch) SetReader(r MatchReader)

func (*DocumentMatch) Size

func (dm *DocumentMatch) Size() int

func (*DocumentMatch) String

func (dm *DocumentMatch) String() string

func (*DocumentMatch) VisitStoredFields

func (dm *DocumentMatch) VisitStoredFields(visitor segment.StoredFieldVisitor) error

type DocumentMatchCollection

type DocumentMatchCollection []*DocumentMatch

func (DocumentMatchCollection) Len

func (c DocumentMatchCollection) Len() int

func (DocumentMatchCollection) Less

func (c DocumentMatchCollection) Less(i, j int) bool

func (DocumentMatchCollection) Swap

func (c DocumentMatchCollection) Swap(i, j int)

type DocumentMatchIterator

type DocumentMatchIterator interface {
	Next() (*DocumentMatch, error)
	Aggregations() *Bucket
}

type DocumentMatchPool

type DocumentMatchPool struct {
	TooSmall DocumentMatchPoolTooSmall
	// contains filtered or unexported fields
}

DocumentMatchPool manages use/re-use of DocumentMatch instances it pre-allocates space from a single large block with the expected number of instances. It is not thread-safe as currently all aspects of search take place in a single goroutine.

func NewDocumentMatchPool

func NewDocumentMatchPool(size, sortSize int) *DocumentMatchPool

NewDocumentMatchPool will build a DocumentMatchPool with memory pre-allocated to accommodate the requested number of DocumentMatch instances

func (*DocumentMatchPool) Get

func (p *DocumentMatchPool) Get() *DocumentMatch

Get returns an available DocumentMatch from the pool if the pool was not allocated with sufficient size, an allocation will occur to satisfy this request. As a side-effect this will grow the size of the pool.

func (*DocumentMatchPool) Put

func (p *DocumentMatchPool) Put(d *DocumentMatch)

Put returns a DocumentMatch to the pool

type DocumentMatchPoolTooSmall

type DocumentMatchPoolTooSmall func(p *DocumentMatchPool) *DocumentMatch

DocumentMatchPoolTooSmall is a callback function that can be executed when the DocumentMatchPool does not have sufficient capacity By default we just perform just-in-time allocation, but you could log a message, or panic, etc.

type DocumentValueReadable

type DocumentValueReadable interface {
	// DocumentValueReader provides a way to find all of the document
	// values stored in the specified fields.  The returned
	// DocumentValueReader provides a means to visit specific document
	// numbers.
	DocumentValueReader(fields []string) (segment.DocumentValueReader, error)
}

type DurationCalculator

type DurationCalculator interface {
	Calculator
	Duration() time.Duration
}

type Explanation

type Explanation struct {
	Value    float64        `json:"value"`
	Message  string         `json:"message"`
	Children []*Explanation `json:"children,omitempty"`
}

func NewExplanation

func NewExplanation(value float64, msg string, children ...*Explanation) *Explanation

func (*Explanation) Size

func (e *Explanation) Size() int

func (*Explanation) String

func (e *Explanation) String() string

type FieldFragmentMap

type FieldFragmentMap map[string][]string

type FieldSource

type FieldSource string

func Field

func Field(field string) FieldSource

func (FieldSource) Date

func (f FieldSource) Date(match *DocumentMatch) time.Time

func (FieldSource) Dates

func (f FieldSource) Dates(match *DocumentMatch) []time.Time

func (FieldSource) Fields

func (f FieldSource) Fields() []string

func (FieldSource) GeoPoint

func (f FieldSource) GeoPoint(match *DocumentMatch) *geo.Point

func (FieldSource) GeoPoints

func (f FieldSource) GeoPoints(match *DocumentMatch) []*geo.Point

func (FieldSource) Number

func (f FieldSource) Number(match *DocumentMatch) float64

func (FieldSource) Numbers

func (f FieldSource) Numbers(match *DocumentMatch) []float64

func (FieldSource) Value

func (f FieldSource) Value(match *DocumentMatch) []byte

func (FieldSource) Values

func (f FieldSource) Values(match *DocumentMatch) [][]byte

type FieldTermLocation

type FieldTermLocation struct {
	Field    string
	Term     string
	Location Location
}

func MergeFieldTermLocations

func MergeFieldTermLocations(dest []FieldTermLocation, matches []*DocumentMatch) []FieldTermLocation

type FieldTermLocationMap

type FieldTermLocationMap map[string]TermLocationMap

func MergeLocations

func MergeLocations(locations []FieldTermLocationMap) FieldTermLocationMap

type FilteringTextSource

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

func FilterText

func FilterText(source TextValuesSource, filter func([]byte) bool) *FilteringTextSource

func (*FilteringTextSource) Fields

func (f *FilteringTextSource) Fields() []string

func (*FilteringTextSource) Values

func (f *FilteringTextSource) Values(match *DocumentMatch) [][]byte

type GeoPointValueSource

type GeoPointValueSource interface {
	Fields() []string
	GeoPoint(match *DocumentMatch) *geo.Point
}

type GeoPointValuesSource

type GeoPointValuesSource interface {
	Fields() []string
	GeoPoints(match *DocumentMatch) []*geo.Point
}

type Location

type Location struct {
	Pos   int
	Start int
	End   int
}

func (*Location) Size

func (l *Location) Size() int

type Locations

type Locations []*Location

func (Locations) Dedupe

func (p Locations) Dedupe() Locations

func (Locations) Len

func (p Locations) Len() int

func (Locations) Less

func (p Locations) Less(i, j int) bool

func (Locations) Swap

func (p Locations) Swap(i, j int)

type MatchReader

type MatchReader interface {
	DocumentValueReadable
	StoredFieldVisitable
}

type MetricCalculator

type MetricCalculator interface {
	Calculator
	Value() float64
}

type MissingDateSource

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

func MissingDate

func MissingDate(primary, replacement DateValuesSource) *MissingDateSource

func (*MissingDateSource) Fields

func (f *MissingDateSource) Fields() []string

func (*MissingDateSource) Numbers

func (f *MissingDateSource) Numbers(match *DocumentMatch) []time.Time

type MissingGeoPointSource

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

func MissingGeoPoints

func MissingGeoPoints(primary, replacement GeoPointValuesSource) *MissingGeoPointSource

func (*MissingGeoPointSource) Fields

func (f *MissingGeoPointSource) Fields() []string

func (*MissingGeoPointSource) GeoPoints

func (f *MissingGeoPointSource) GeoPoints(match *DocumentMatch) []*geo.Point

type MissingNumericSource

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

func MissingNumeric

func MissingNumeric(primary, replacement NumericValuesSource) *MissingNumericSource

func (*MissingNumericSource) Fields

func (f *MissingNumericSource) Fields() []string

func (*MissingNumericSource) Numbers

func (f *MissingNumericSource) Numbers(match *DocumentMatch) []float64

type MissingTextValueSource

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

func MissingTextValue

func MissingTextValue(primary, replacement TextValueSource) *MissingTextValueSource

func (*MissingTextValueSource) Fields

func (f *MissingTextValueSource) Fields() []string

func (*MissingTextValueSource) Value

func (f *MissingTextValueSource) Value(match *DocumentMatch) []byte

type NumericValueSource

type NumericValueSource interface {
	Fields() []string
	Number(match *DocumentMatch) float64
}

type NumericValuesSource

type NumericValuesSource interface {
	Fields() []string
	Numbers(match *DocumentMatch) []float64
}

type PointDistanceSource

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

func NewGeoPointDistanceSource

func NewGeoPointDistanceSource(a, b GeoPointValueSource, unit geo.DistanceUnit) *PointDistanceSource

func (PointDistanceSource) Fields

func (p PointDistanceSource) Fields() []string

func (PointDistanceSource) Number

func (p PointDistanceSource) Number(match *DocumentMatch) float64

func (PointDistanceSource) Numbers

func (p PointDistanceSource) Numbers(match *DocumentMatch) []float64

func (PointDistanceSource) Value

func (p PointDistanceSource) Value(match *DocumentMatch) []byte

func (PointDistanceSource) Values

func (p PointDistanceSource) Values(match *DocumentMatch) [][]byte

type Reader

type Reader interface {
	DocumentValueReadable

	StoredFieldVisitable

	CollectionStats(field string) (segment.CollectionStats, error)

	// DictionaryLookup provides a way to quickly determine if a term is
	// in the dictionary for the specified field.
	DictionaryLookup(field string) (segment.DictionaryLookup, error)

	// DictionaryIterator provides a way to explore the terms used in the
	// specified field.  You can optionally filter these terms
	// by the provided Automaton, or start/end terms.
	DictionaryIterator(field string, automaton segment.Automaton, start,
		end []byte) (segment.DictionaryIterator, error)

	// PostingsIterator provides a way to find information about all documents
	// that use the specified term in the specified field.
	PostingsIterator(term []byte, field string, includeFreq, includeNorm,
		includeTermVectors bool) (segment.PostingsIterator, error)

	// Close releases all resources associated with this Reader
	Close() error
}

type ScoreSource

type ScoreSource struct{}

func DocumentScore

func DocumentScore() *ScoreSource

func (*ScoreSource) Fields

func (n *ScoreSource) Fields() []string

func (*ScoreSource) Number

func (n *ScoreSource) Number(d *DocumentMatch) float64

func (*ScoreSource) Numbers

func (n *ScoreSource) Numbers(d *DocumentMatch) []float64

func (*ScoreSource) Value

func (n *ScoreSource) Value(d *DocumentMatch) []byte

func (*ScoreSource) Values

func (n *ScoreSource) Values(d *DocumentMatch) [][]byte

type Scorer

type Scorer interface {
	Score(freq int, norm float64) float64
	Explain(freq int, norm float64) *Explanation
}

type Searcher

type Searcher interface {
	Next(ctx *Context) (*DocumentMatch, error)
	Advance(ctx *Context, number uint64) (*DocumentMatch, error)
	Close() error
	Count() uint64
	Min() int
	Size() int

	DocumentMatchPoolSize() int
}

type SearcherOptions

type SearcherOptions struct {
	SimilarityForField func(field string) Similarity
	DefaultSearchField string
	DefaultAnalyzer    *analysis.Analyzer
	Explain            bool
	IncludeTermVectors bool
	Score              string
}

type Similarity

type Similarity interface {
	ComputeNorm(numTerms int) float32
	Scorer(boost float64, collectionStats segment.CollectionStats, termStats segment.TermStats) Scorer
}

type Sort

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

func ParseSearchSortString

func ParseSearchSortString(input string) *Sort

func SortBy

func SortBy(source TextValueSource) *Sort

func (*Sort) Desc

func (s *Sort) Desc() *Sort

func (*Sort) Fields

func (s *Sort) Fields() []string

func (*Sort) MissingFirst

func (s *Sort) MissingFirst() *Sort

func (*Sort) Value

func (s *Sort) Value(match *DocumentMatch) []byte

type SortOrder

type SortOrder []*Sort

func ParseSortOrderStrings

func ParseSortOrderStrings(in []string) SortOrder

func (SortOrder) Compare

func (o SortOrder) Compare(i, j *DocumentMatch) int

func (SortOrder) Compute

func (o SortOrder) Compute(match *DocumentMatch)

func (SortOrder) Copy

func (o SortOrder) Copy() SortOrder

func (SortOrder) Fields

func (o SortOrder) Fields() (fields []string)

func (SortOrder) Reverse

func (o SortOrder) Reverse()

type SortValue

type SortValue [][]byte

type StoredFieldVisitable

type StoredFieldVisitable interface {
	// VisitStoredFields will call the visitor for each stored field
	// of the specified document number.
	VisitStoredFields(number uint64, visitor segment.StoredFieldVisitor) error
}

type TermLocationMap

type TermLocationMap map[string]Locations

func MergeTermLocationMaps

func MergeTermLocationMaps(rv, other TermLocationMap) TermLocationMap

func (TermLocationMap) AddLocation

func (t TermLocationMap) AddLocation(term string, location *Location)

type TextValueSource

type TextValueSource interface {
	Fields() []string
	Value(match *DocumentMatch) []byte
}

type TextValuesSource

type TextValuesSource interface {
	Fields() []string
	Values(match *DocumentMatch) [][]byte
}

Directories

Path Synopsis
aggregations
collector
highlight
searcher
similarity