package index

import (
	"fmt"
)

type Index interface {
	Open() error
	Close()

	Update(id []byte, doc []byte) error
	Delete(id []byte) error

	TermFieldReader(term []byte, field string) (TermFieldReader, error)

	DocCount() uint64
}

type TermFieldVector struct {
	Field string
	Pos   uint64
	Start uint64
	End   uint64
}

type TermFieldDoc struct {
	ID      string
	Freq    uint64
	Norm    float64
	Vectors []*TermFieldVector
}

type TermFieldReader interface {
	Next() (*TermFieldDoc, error)
	Advance(ID []byte) (*TermFieldDoc, error)
	Count() uint64
	Close()
}

type Field struct {
	Name               string
	Path               string
	Analyzer           string
	IncludeTermVectors bool
}

func (f *Field) String() string {
	return fmt.Sprintf("Field[name=%s, path=%s, analyzer=%s]", f.Name, f.Path, f.Analyzer)
}
