index

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: BSD-3-Clause Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	Id         string
	Score      float32
	Properties map[string]interface{}
}

Document represents a single document to be indexed or returned from a query. Besides a score and id, the Properties are completely arbitrary

func NewDocument

func NewDocument(id string, score float32) Document

NewDocument creates a document with the specific id and score

func (Document) Set

func (d Document) Set(name string, value interface{}) Document

Set sets a property and its value in the document

type DocumentList

type DocumentList []Document

DocumentList is used to sort documents by descending score

func (DocumentList) Len

func (l DocumentList) Len() int

func (DocumentList) Less

func (l DocumentList) Less(i, j int) bool

func (DocumentList) Sort

func (l DocumentList) Sort()

Sort the DocumentList

func (DocumentList) Swap

func (l DocumentList) Swap(i, j int)

type Field

type Field struct {
	Name    string
	Type    FieldType
	Options interface{}
}

Field represents a single field's metadata

func NewNumericField

func NewNumericField(name string) Field

NewNumericField creates a new numeric field with the given name

func NewTextField

func NewTextField(name string, weight float32) Field

NewTextField creates a new text field with the given weight

func NewTextFieldSortable

func NewTextFieldSortable(name string, weight float32) Field

type FieldType

type FieldType int

FieldType is an enumeration of field/property types

const (
	// TextField full-text field
	TextField FieldType = iota

	// NumericField numeric range field
	NumericField

	// GeoField geo-indexed point field
	GeoField

	// ValueField as-as short text value to be hashed and indexed
	ValueField

	// NoIndexField A field that shuold not be indexed
	NoIndexField
)

type Index

type Index interface {
	GetName() string
	Index(documents []Document, options interface{}) error
	FullTextQuerySingleField(query.Query, int) (docs []Document, total int, err error)
	PrefixQuery(query.Query, int) (docs []Document, total int, err error)
	SuffixQuery(query.Query, int) (docs []Document, total int, err error)
	WildCardQuery(query.Query, int) (docs []Document, total int, err error)
	ContainsQuery(q query.Query, debug int) (docs []Document, total int, err error)
	Drop() error
	DocumentCount() int64
	Create() error
}

Index is the abstract representation of a search index we're working against. It is implemented for redisearch, elasticserch and solr.

type Metadata

type Metadata struct {
	Fields  []Field
	Options interface{}
}

Metadata represents an index schema metadata, or how the index would treat documents sent to it.

func NewMetadata

func NewMetadata() *Metadata

NewMetadata creates a new Metadata object

func (*Metadata) AddField

func (m *Metadata) AddField(f Field) *Metadata

AddField adds a field to the Metadata object

type TextFieldOptions

type TextFieldOptions struct {
	Weight   float32
	Stemming bool
	Sortable bool
}

TextFieldOptions Options for text fields - weight and stemming enabled/disabled.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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