fulltext

package module
v0.0.0-...-8d67774 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package fulltext provides a fulltext indexing service using trigram indexing and suffix arrays. It is designed for ASCII character sets but will attmept to transiliterare others.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

type Doc struct {
	ID        uint64 // external ID not managed by the index.  It is the caller's responsibility to ensure uniqueness
	Text      string // the text to index
	PriorText string // the text that was previously indexed.  This is required for updates only - leave empty for new documents
}

Doc is a document to be indexed

type Service

type Service struct {
	sync.RWMutex // protects docs and idx
	// contains filtered or unexported fields
}

Service implements pb.FulltextServiceServer

func NewService

func NewService() *Service

NewService initializes a fulltext index service

func (*Service) DocCount

func (svc *Service) DocCount() int

DocCount returns the number of documents in the index

func (*Service) Search

func (svc *Service) Search(ctx context.Context, query string) (docIDs []uint64, err error)

Search performs a fulltext search suitable for a typeahead search box. The returned docIDs are the external IDs provided at time of indexing.

func (*Service) Upsert

func (svc *Service) Upsert(ctx context.Context, docs []Doc) (err error)

Upsert adds or updates a document in the full text index

Jump to

Keyboard shortcuts

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