bleve: github.com/blevesearch/bleve/search Index | Files | Directories

package search

import "github.com/blevesearch/bleve/search"

Index

Package Files

collector.go explanation.go facets_builder.go levenshtein.go pool.go search.go sort.go util.go

Variables

var HighTerm = strings.Repeat(string([]byte{0xff}), 10)
var LowTerm = string([]byte{0x00})

func LevenshteinDistance Uses

func LevenshteinDistance(a, b string) int

func LevenshteinDistanceMax Uses

func LevenshteinDistanceMax(a, b string, max int) (int, bool)

LevenshteinDistanceMax same as LevenshteinDistance but attempts to bail early once we know the distance will be greater than max in which case the first return val will be the max and the second will be true, indicating max was exceeded

type ArrayPositions Uses

type ArrayPositions []uint64

func (ArrayPositions) Equals Uses

func (ap ArrayPositions) Equals(other ArrayPositions) bool

type Collector Uses

type Collector interface {
    Collect(ctx context.Context, searcher Searcher, reader index.IndexReader) error
    Results() DocumentMatchCollection
    Total() uint64
    MaxScore() float64
    Took() time.Duration
    SetFacetsBuilder(facetsBuilder *FacetsBuilder)
    FacetResults() FacetResults
}

type DateRangeFacet Uses

type DateRangeFacet struct {
    Name  string  `json:"name"`
    Start *string `json:"start,omitempty"`
    End   *string `json:"end,omitempty"`
    Count int     `json:"count"`
}

func (*DateRangeFacet) Same Uses

func (drf *DateRangeFacet) Same(other *DateRangeFacet) bool

type DateRangeFacets Uses

type DateRangeFacets []*DateRangeFacet

func (DateRangeFacets) Add Uses

func (drf DateRangeFacets) Add(dateRangeFacet *DateRangeFacet) DateRangeFacets

func (DateRangeFacets) Len Uses

func (drf DateRangeFacets) Len() int

func (DateRangeFacets) Less Uses

func (drf DateRangeFacets) Less(i, j int) bool

func (DateRangeFacets) Swap Uses

func (drf DateRangeFacets) Swap(i, j int)

type DocumentMatch Uses

type DocumentMatch struct {
    Index           string                `json:"index,omitempty"`
    ID              string                `json:"id"`
    IndexInternalID index.IndexInternalID `json:"-"`
    Score           float64               `json:"score"`
    Expl            *Explanation          `json:"explanation,omitempty"`
    Locations       FieldTermLocationMap  `json:"locations,omitempty"`
    Fragments       FieldFragmentMap      `json:"fragments,omitempty"`
    Sort            []string              `json:"sort,omitempty"`

    // Fields contains the values for document fields listed in
    // SearchRequest.Fields. Text fields are returned as strings, numeric
    // fields as float64s and date fields as time.RFC3339 formatted strings.
    Fields map[string]interface{} `json:"fields,omitempty"`

    // if we load the document for this hit, remember it so we dont load again
    Document *document.Document `json:"-"`

    // used to maintain natural index order
    HitNumber uint64 `json:"-"`
}

func (*DocumentMatch) AddFieldValue Uses

func (dm *DocumentMatch) AddFieldValue(name string, value interface{})

func (*DocumentMatch) Reset Uses

func (dm *DocumentMatch) Reset() *DocumentMatch

Reset allows an already allocated DocumentMatch to be reused

func (*DocumentMatch) String Uses

func (dm *DocumentMatch) String() string

type DocumentMatchCollection Uses

type DocumentMatchCollection []*DocumentMatch

func (DocumentMatchCollection) Len Uses

func (c DocumentMatchCollection) Len() int

func (DocumentMatchCollection) Less Uses

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

func (DocumentMatchCollection) Swap Uses

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

type DocumentMatchPool Uses

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 Uses

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 Uses

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 Uses

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

Put returns a DocumentMatch to the pool

type DocumentMatchPoolTooSmall Uses

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 Explanation Uses

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

func (*Explanation) String Uses

func (expl *Explanation) String() string

type FacetBuilder Uses

type FacetBuilder interface {
    StartDoc()
    UpdateVisitor(field string, term []byte)
    EndDoc()

    Result() *FacetResult
    Field() string
}

type FacetResult Uses

type FacetResult struct {
    Field         string             `json:"field"`
    Total         int                `json:"total"`
    Missing       int                `json:"missing"`
    Other         int                `json:"other"`
    Terms         TermFacets         `json:"terms,omitempty"`
    NumericRanges NumericRangeFacets `json:"numeric_ranges,omitempty"`
    DateRanges    DateRangeFacets    `json:"date_ranges,omitempty"`
}

func (*FacetResult) Fixup Uses

func (fr *FacetResult) Fixup(size int)

func (*FacetResult) Merge Uses

func (fr *FacetResult) Merge(other *FacetResult)

type FacetResults Uses

type FacetResults map[string]*FacetResult

func (FacetResults) Fixup Uses

func (fr FacetResults) Fixup(name string, size int)

func (FacetResults) Merge Uses

func (fr FacetResults) Merge(other FacetResults)

type FacetsBuilder Uses

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

func NewFacetsBuilder Uses

func NewFacetsBuilder(indexReader index.IndexReader) *FacetsBuilder

func (*FacetsBuilder) Add Uses

func (fb *FacetsBuilder) Add(name string, facetBuilder FacetBuilder)

func (*FacetsBuilder) EndDoc Uses

func (fb *FacetsBuilder) EndDoc()

func (*FacetsBuilder) RequiredFields Uses

func (fb *FacetsBuilder) RequiredFields() []string

func (*FacetsBuilder) Results Uses

func (fb *FacetsBuilder) Results() FacetResults

func (*FacetsBuilder) StartDoc Uses

func (fb *FacetsBuilder) StartDoc()

func (*FacetsBuilder) UpdateVisitor Uses

func (fb *FacetsBuilder) UpdateVisitor(field string, term []byte)

type FieldFragmentMap Uses

type FieldFragmentMap map[string][]string

type FieldTermLocationMap Uses

type FieldTermLocationMap map[string]TermLocationMap

func MergeLocations Uses

func MergeLocations(locations []FieldTermLocationMap) FieldTermLocationMap

type Location Uses

type Location struct {
    // Pos is the position of the term within the field, starting at 1
    Pos uint64 `json:"pos"`

    // Start and End are the byte offsets of the term in the field
    Start uint64 `json:"start"`
    End   uint64 `json:"end"`

    // ArrayPositions contains the positions of the term within any elements.
    ArrayPositions ArrayPositions `json:"array_positions"`
}

type Locations Uses

type Locations []*Location

type NumericRangeFacet Uses

type NumericRangeFacet struct {
    Name  string   `json:"name"`
    Min   *float64 `json:"min,omitempty"`
    Max   *float64 `json:"max,omitempty"`
    Count int      `json:"count"`
}

func (*NumericRangeFacet) Same Uses

func (nrf *NumericRangeFacet) Same(other *NumericRangeFacet) bool

type NumericRangeFacets Uses

type NumericRangeFacets []*NumericRangeFacet

func (NumericRangeFacets) Add Uses

func (nrf NumericRangeFacets) Add(numericRangeFacet *NumericRangeFacet) NumericRangeFacets

func (NumericRangeFacets) Len Uses

func (nrf NumericRangeFacets) Len() int

func (NumericRangeFacets) Less Uses

func (nrf NumericRangeFacets) Less(i, j int) bool

func (NumericRangeFacets) Swap Uses

func (nrf NumericRangeFacets) Swap(i, j int)

type SearchContext Uses

type SearchContext struct {
    DocumentMatchPool *DocumentMatchPool
}

SearchContext represents the context around a single search

type SearchSort Uses

type SearchSort interface {
    UpdateVisitor(field string, term []byte)
    Value(a *DocumentMatch) string
    Descending() bool

    RequiresDocID() bool
    RequiresScoring() bool
    RequiresFields() []string

    Copy() SearchSort
}

func ParseSearchSortJSON Uses

func ParseSearchSortJSON(input json.RawMessage) (SearchSort, error)

func ParseSearchSortObj Uses

func ParseSearchSortObj(input map[string]interface{}) (SearchSort, error)

func ParseSearchSortString Uses

func ParseSearchSortString(input string) SearchSort

type Searcher Uses

type Searcher interface {
    Next(ctx *SearchContext) (*DocumentMatch, error)
    Advance(ctx *SearchContext, ID index.IndexInternalID) (*DocumentMatch, error)
    Close() error
    Weight() float64
    SetQueryNorm(float64)
    Count() uint64
    Min() int

    DocumentMatchPoolSize() int
}

type SearcherOptions Uses

type SearcherOptions struct {
    Explain            bool
    IncludeTermVectors bool
}

type SortDocID Uses

type SortDocID struct {
    Desc bool
}

SortDocID will sort results by the document identifier

func (*SortDocID) Copy Uses

func (s *SortDocID) Copy() SearchSort

func (*SortDocID) Descending Uses

func (s *SortDocID) Descending() bool

Descending determines the order of the sort

func (*SortDocID) MarshalJSON Uses

func (s *SortDocID) MarshalJSON() ([]byte, error)

func (*SortDocID) RequiresDocID Uses

func (s *SortDocID) RequiresDocID() bool

RequiresDocID says this SearchSort does require the DocID be loaded

func (*SortDocID) RequiresFields Uses

func (s *SortDocID) RequiresFields() []string

RequiresFields says this SearchStore does not require any stored fields

func (*SortDocID) RequiresScoring Uses

func (s *SortDocID) RequiresScoring() bool

RequiresScoring says this SearchStore does not require scoring

func (*SortDocID) UpdateVisitor Uses

func (s *SortDocID) UpdateVisitor(field string, term []byte)

UpdateVisitor is a no-op for SortDocID as it's value is not dependent on any field terms

func (*SortDocID) Value Uses

func (s *SortDocID) Value(i *DocumentMatch) string

Value returns the sort value of the DocumentMatch

type SortField Uses

type SortField struct {
    Field   string
    Desc    bool
    Type    SortFieldType
    Mode    SortFieldMode
    Missing SortFieldMissing
    // contains filtered or unexported fields
}

SortField will sort results by the value of a stored field

Field is the name of the field
Descending reverse the sort order (default false)
Type allows forcing of string/number/date behavior (default auto)
Mode controls behavior for multi-values fields (default first)
Missing controls behavior of missing values (default last)

func (*SortField) Copy Uses

func (s *SortField) Copy() SearchSort

func (*SortField) Descending Uses

func (s *SortField) Descending() bool

Descending determines the order of the sort

func (*SortField) MarshalJSON Uses

func (s *SortField) MarshalJSON() ([]byte, error)

func (*SortField) RequiresDocID Uses

func (s *SortField) RequiresDocID() bool

RequiresDocID says this SearchSort does not require the DocID be loaded

func (*SortField) RequiresFields Uses

func (s *SortField) RequiresFields() []string

RequiresFields says this SearchStore requires the specified stored field

func (*SortField) RequiresScoring Uses

func (s *SortField) RequiresScoring() bool

RequiresScoring says this SearchStore does not require scoring

func (*SortField) UpdateVisitor Uses

func (s *SortField) UpdateVisitor(field string, term []byte)

UpdateVisitor notifies this sort field that in this document this field has the specified term

func (*SortField) Value Uses

func (s *SortField) Value(i *DocumentMatch) string

Value returns the sort value of the DocumentMatch it also resets the state of this SortField for processing the next document

type SortFieldMissing Uses

type SortFieldMissing int

SortFieldMissing controls where documents missing a field value should be sorted

const (
    // SortFieldMissingLast sorts documents missing a field at the end
    SortFieldMissingLast SortFieldMissing = iota

    // SortFieldMissingFirst sorts documents missing a field at the beginning
    SortFieldMissingFirst
)

type SortFieldMode Uses

type SortFieldMode int

SortFieldMode describes the behavior if the field has multiple values

const (
    // SortFieldDefault uses the first (or only) value, this is the default zero-value
    SortFieldDefault SortFieldMode = iota // FIXME name is confusing
    // SortFieldMin uses the minimum value
    SortFieldMin
    // SortFieldMax uses the maximum value
    SortFieldMax
)

type SortFieldType Uses

type SortFieldType int

SortFieldType lets you control some internal sort behavior normally leaving this to the zero-value of SortFieldAuto is fine

const (
    // SortFieldAuto applies heuristics attempt to automatically sort correctly
    SortFieldAuto SortFieldType = iota
    // SortFieldAsString forces sort as string (no prefix coded terms removed)
    SortFieldAsString
    // SortFieldAsNumber forces sort as string (prefix coded terms with shift > 0 removed)
    SortFieldAsNumber
    // SortFieldAsDate forces sort as string (prefix coded terms with shift > 0 removed)
    SortFieldAsDate
)

type SortGeoDistance Uses

type SortGeoDistance struct {
    Field string
    Desc  bool
    Unit  string

    Lon float64
    Lat float64
    // contains filtered or unexported fields
}

SortGeoDistance will sort results by the distance of an indexed geo point, from the provided location.

Field is the name of the field
Descending reverse the sort order (default false)

func NewSortGeoDistance Uses

func NewSortGeoDistance(field, unit string, lon, lat float64, desc bool) (
    *SortGeoDistance, error)

NewSortGeoDistance creates SearchSort instance for sorting documents by their distance from the specified point.

func (*SortGeoDistance) Copy Uses

func (s *SortGeoDistance) Copy() SearchSort

func (*SortGeoDistance) Descending Uses

func (s *SortGeoDistance) Descending() bool

Descending determines the order of the sort

func (*SortGeoDistance) MarshalJSON Uses

func (s *SortGeoDistance) MarshalJSON() ([]byte, error)

func (*SortGeoDistance) RequiresDocID Uses

func (s *SortGeoDistance) RequiresDocID() bool

RequiresDocID says this SearchSort does not require the DocID be loaded

func (*SortGeoDistance) RequiresFields Uses

func (s *SortGeoDistance) RequiresFields() []string

RequiresFields says this SearchStore requires the specified stored field

func (*SortGeoDistance) RequiresScoring Uses

func (s *SortGeoDistance) RequiresScoring() bool

RequiresScoring says this SearchStore does not require scoring

func (*SortGeoDistance) UpdateVisitor Uses

func (s *SortGeoDistance) UpdateVisitor(field string, term []byte)

UpdateVisitor notifies this sort field that in this document this field has the specified term

func (*SortGeoDistance) Value Uses

func (s *SortGeoDistance) Value(i *DocumentMatch) string

Value returns the sort value of the DocumentMatch it also resets the state of this SortField for processing the next document

type SortOrder Uses

type SortOrder []SearchSort

func ParseSortOrderJSON Uses

func ParseSortOrderJSON(in []json.RawMessage) (SortOrder, error)

func ParseSortOrderStrings Uses

func ParseSortOrderStrings(in []string) SortOrder

func (SortOrder) CacheDescending Uses

func (so SortOrder) CacheDescending() []bool

func (SortOrder) CacheIsScore Uses

func (so SortOrder) CacheIsScore() []bool

func (SortOrder) Compare Uses

func (so SortOrder) Compare(cachedScoring, cachedDesc []bool, i, j *DocumentMatch) int

Compare will compare two document matches using the specified sort order if both are numbers, we avoid converting back to term

func (SortOrder) Copy Uses

func (so SortOrder) Copy() SortOrder

func (SortOrder) RequiredFields Uses

func (so SortOrder) RequiredFields() []string

func (SortOrder) RequiresDocID Uses

func (so SortOrder) RequiresDocID() bool

func (SortOrder) RequiresScore Uses

func (so SortOrder) RequiresScore() bool

func (SortOrder) UpdateVisitor Uses

func (so SortOrder) UpdateVisitor(field string, term []byte)

func (SortOrder) Value Uses

func (so SortOrder) Value(doc *DocumentMatch)

type SortScore Uses

type SortScore struct {
    Desc bool
}

SortScore will sort results by the document match score

func (*SortScore) Copy Uses

func (s *SortScore) Copy() SearchSort

func (*SortScore) Descending Uses

func (s *SortScore) Descending() bool

Descending determines the order of the sort

func (*SortScore) MarshalJSON Uses

func (s *SortScore) MarshalJSON() ([]byte, error)

func (*SortScore) RequiresDocID Uses

func (s *SortScore) RequiresDocID() bool

RequiresDocID says this SearchSort does not require the DocID be loaded

func (*SortScore) RequiresFields Uses

func (s *SortScore) RequiresFields() []string

RequiresFields says this SearchStore does not require any store fields

func (*SortScore) RequiresScoring Uses

func (s *SortScore) RequiresScoring() bool

RequiresScoring says this SearchStore does require scoring

func (*SortScore) UpdateVisitor Uses

func (s *SortScore) UpdateVisitor(field string, term []byte)

UpdateVisitor is a no-op for SortScore as it's value is not dependent on any field terms

func (*SortScore) Value Uses

func (s *SortScore) Value(i *DocumentMatch) string

Value returns the sort value of the DocumentMatch

type TermFacet Uses

type TermFacet struct {
    Term  string `json:"term"`
    Count int    `json:"count"`
}

type TermFacets Uses

type TermFacets []*TermFacet

func (TermFacets) Add Uses

func (tf TermFacets) Add(termFacet *TermFacet) TermFacets

func (TermFacets) Len Uses

func (tf TermFacets) Len() int

func (TermFacets) Less Uses

func (tf TermFacets) Less(i, j int) bool

func (TermFacets) Swap Uses

func (tf TermFacets) Swap(i, j int)

type TermLocationMap Uses

type TermLocationMap map[string]Locations

func MergeTermLocationMaps Uses

func MergeTermLocationMaps(rv, other TermLocationMap) TermLocationMap

func (TermLocationMap) AddLocation Uses

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

Directories

PathSynopsis
collector
facet
highlight
highlight/format/ansi
highlight/format/html
highlight/fragmenter/simple
highlight/highlighter/ansi
highlight/highlighter/html
highlight/highlighter/simple
query
scorer
searcher

Package search imports 11 packages (graph) and is imported by 152 packages. Updated 2017-09-02. Refresh now. Tools for package owners.