Documentation
¶
Overview ¶
Package xapian is a thin cgo binding over the Xapian C++ search library. It exposes only writable/read databases, documents, queries and search results, with no application-domain assumptions, so it can be reused by any Go program that needs full-text search on top of Xapian.
cgo cannot call C++ directly (name mangling, templates, exceptions, RAII), so every call crosses through the extern "C" shim in shim.cc / shim.h, which converts Xapian C++ exceptions into malloc'd error strings. All handles are opaque pointers owned by the caller until the matching Close/Free.
The package requires libxapian with its development headers at build time.
Index ¶
- Constants
- type DB
- type Doc
- type MSetEntry
- type Op
- type Query
- type WDB
- func (w *WDB) Close()
- func (w *WDB) Commit() error
- func (w *WDB) DeleteDocument(docid uint32) (existed bool, err error)
- func (w *WDB) DocCount() (uint32, error)
- func (w *WDB) DocExists(docid uint32) (bool, error)
- func (w *WDB) GetMetadata(key string) (string, error)
- func (w *WDB) ReplaceDocument(docid uint32, d *Doc) error
- func (w *WDB) SetMetadata(key, value string) error
Constants ¶
const ( OpAND = Op(C.FCX_OP_AND) OpOR = Op(C.FCX_OP_OR) OpANDNOT = Op(C.FCX_OP_AND_NOT) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a read-only Xapian database, optionally combining several on-disk shards into one searchable view.
func OpenDBMulti ¶
OpenDBMulti opens paths as one combined read-only database. An empty paths slice returns (nil, nil).
type Doc ¶
type Doc struct {
// contains filtered or unexported fields
}
Doc is a Xapian document under construction.
func NewDoc ¶
func NewDoc() *Doc
NewDoc allocates an empty document. The caller must Free it (or hand it to WDB.ReplaceDocument, which does not take ownership — Free it afterwards).
func (*Doc) AddBooleanTerm ¶
AddBooleanTerm indexes a boolean (filter) term.
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query is a Xapian query tree node.
func QueryCombine ¶
QueryCombine joins a and b under op. It consumes a and b (both are freed here) and returns the combined query.
func QueryMatchAll ¶
QueryMatchAll builds a query that matches every document.
func QueryWildcard ¶
QueryWildcard builds a wildcard (prefix) query from pattern.
type WDB ¶
type WDB struct {
// contains filtered or unexported fields
}
WDB is a writable Xapian database handle.
func (*WDB) DeleteDocument ¶
DeleteDocument removes docid. existed reports whether it was present; a not-found document is not an error.
func (*WDB) GetMetadata ¶
GetMetadata reads a metadata value; a missing key returns "".
func (*WDB) ReplaceDocument ¶
ReplaceDocument stores d under docid, replacing any existing document.
func (*WDB) SetMetadata ¶
SetMetadata stores an arbitrary key/value pair in the database metadata.