XapianDatabase

XapianDatabase — A read-only database

Functions

Properties

XapianDatabaseBackend backend Read / Write / Construct Only
XapianDatabaseFlags flags Read / Write / Construct Only
guint64 offset Read / Write / Construct Only
gchar * path Read / Write / Construct Only

Types and Values

Object Hierarchy

    GEnum
    ╰── XapianDatabaseBackend
    GFlags
    ├── XapianDatabaseCompactFlags
    ╰── XapianDatabaseFlags
    GObject
    ╰── XapianDatabase
        ╰── XapianWritableDatabase

Description

XapianDatabase is a class that allows read-only access to a Xapian database at a given path.

Typically, you will use XapianDatabase to open a database for querying, by using the XapianEnquire class.

Functions

xapian_database_new ()

XapianDatabase *
xapian_database_new (GError **error);

Creates and initializes a new, empty XapianDatabase instance.

If the initialization was not successful, error is set.

Parameters

error

return location for a GError, or NULL

 

Returns

the newly created XapianDatabase instance, or NULL if the initialization failed.

[transfer full]


xapian_database_new_with_path ()

XapianDatabase *
xapian_database_new_with_path (const char *path,
                               GError **error);

Creates and initializes a new XapianDatabase at path .

If the initialization was not successful, error is set.

Parameters

path

the path to the database

 

error

return location for a GError, or NULL

 

Returns

the newly created XapianDatabase instance for the given path , or NULL if the initialization failed.

[transfer full]


xapian_database_close ()

void
xapian_database_close (XapianDatabase *db);

Explicitly closes a database.

XapianDatabase instances are implicitly closed when being finalized, so you'll rarely need to call this function.

Parameters

db

a XapianDatabase

 

xapian_database_reopen ()

void
xapian_database_reopen (XapianDatabase *db);

Reopens a XapianDatabase.

Parameters

db

a XapianDatabase

 

Since: 1.2


xapian_database_get_description ()

char *
xapian_database_get_description (XapianDatabase *db);

Retrieves a string describing the XapianDatabase.

Typically, this function is used when debugging.

Parameters

db

a XapianDatabase

 

Returns

a description of the database.

[transfer full]


xapian_database_get_uuid ()

char *
xapian_database_get_uuid (XapianDatabase *db);

Retrieves a unique identifier for a XapianDatabase.

Parameters

db

a XapianDatabase

 

Returns

a unique identifier for the database.

[transfer full]


xapian_database_get_metadata ()

char *
xapian_database_get_metadata (XapianDatabase *db,
                              const char *key,
                              GError **error);

Retrieves custom metadata associated to a key inside the XapianDatabase.

In case of error, this function returns NULL and sets the error argument.

Parameters

db

a XapianDatabase

 

key

a key to access in the database metadata

 

error

return location for a GError

 

Returns

the stored metadata.

[transfer full]


xapian_database_get_doc_count ()

unsigned int
xapian_database_get_doc_count (XapianDatabase *db);

Retrieves the number of documents in the database.

Parameters

db

a XapianDatabase

 

Returns

the number of documents in the database


xapian_database_get_last_doc_id ()

unsigned int
xapian_database_get_last_doc_id (XapianDatabase *db);

Retrieves the highest document id in use in the database

Parameters

db

a XapianDatabase

 

Returns

the highest document id in use


xapian_database_get_average_length ()

double
xapian_database_get_average_length (XapianDatabase *db);

Retrieves the average document length in the database

Parameters

db

a XapianDatabase

 

Returns

the average document length in the database

Since: 1.4


xapian_database_get_document ()

XapianDocument *
xapian_database_get_document (XapianDatabase *db,
                              unsigned int docid,
                              GError **error);

Retrieves the XapianDocument with the given docid inside the database.

If the docid was not found, error is set and NULL is returned.

Parameters

db

a XapianDatabase

 

docid

the document id to retrieve

 

error

return location for a GError, or NULL

 

Returns

a XapianDocument instance.

[transfer full]


xapian_database_get_term_freq ()

unsigned int
xapian_database_get_term_freq (XapianDatabase *db,
                               const char *term);

Retrieves the term frequency for term , i.e. the number of different documents that term indexes.

Parameters

db

a XapianDatabase

 

term

the term

 

Returns

the term frequency for term

Since: 1.4


xapian_database_get_collection_freq ()

unsigned int
xapian_database_get_collection_freq (XapianDatabase *db,
                                     const char *term);

Retrieves the collection frequency for term , i.e. the total number of times that the term occurs in all documents in the collection.

Parameters

db

a XapianDatabase

 

term

the term

 

Returns

the collection frequency for term

Since: 1.4


xapian_database_add_database ()

void
xapian_database_add_database (XapianDatabase *db,
                              XapianDatabase *new_db);

Adds an existing database (or group of databases) to those accessed by db .

Parameters

db

a XapianDatabase

 

new_db

a XapianDatabase

 

xapian_database_compact_to_path ()

void
xapian_database_compact_to_path (XapianDatabase *self,
                                 const char *path,
                                 XapianDatabaseCompactFlags flags);

Compacts the database, and writes the result to the given path.

Parameters

self

A XapianDatabase

 

path

The path to write the compacted database to.

 

flags

Flags to compact the database with.

 

Since: 1.4


xapian_database_compact_to_fd ()

void
xapian_database_compact_to_fd (XapianDatabase *self,
                               int fd,
                               XapianDatabaseCompactFlags flags);

Compacts the database, and writes the result to the given fd.

Parameters

self

A XapianDatabase

 

fd

The fd to write the compacted database.

 

flags

Flags to compact the database with.

 

Since: 1.4


xapian_database_enumerate_all_terms ()

XapianTermIterator *
xapian_database_enumerate_all_terms (XapianDatabase *self,
                                     const char *prefix);

Start iterating over all terms in the database, optionally restricted to terms with the specified prefix.

Parameters

self

A XapianDatabase

 

prefix

Prefix to iterate over.

[nullable]

Returns

a XapianTermIterator instance.

[transfer full]

Since: 1.4

Types and Values

enum XapianDatabaseFlags

Flags used when opening a database

Members

XAPIAN_DATABASE_FLAGS_NONE

No flags

 

XAPIAN_DATABASE_FLAGS_NO_SYNC

Do not sync changes to disk

 

XAPIAN_DATABASE_FLAGS_FULL_SYNC

Attempt to fully sync changes to disk

 

XAPIAN_DATABASE_FLAGS_DANGEROUS

Update the database in-place

 

XAPIAN_DATABASE_FLAGS_NO_TERMLIST

Do not create a termlist table

 

XAPIAN_DATABASE_FLAGS_RETRY_LOCK

Retry the lock

 

Since: 1.4


enum XapianDatabaseBackend

The Xapian database backend to use when opening a database.

Members

XAPIAN_DATABASE_BACKEND_DEFAULT

Use the default backend

 

XAPIAN_DATABASE_BACKEND_GLASS

Use the Glass backend

 

XAPIAN_DATABASE_BACKEND_CHERT

Use the Chert backend

 

XAPIAN_DATABASE_BACKEND_STUB

Open a stub database

 

XAPIAN_DATABASE_BACKEND_INMEMORY

Use the "in memory" backend

 

Since: 1.4


enum XapianDatabaseCompactFlags

Compacting policies for XapianDatabase.

Members

XAPIAN_DATABASE_COMPACT_FLAGS_NO_RENUMBER

Use the same document ids

 

XAPIAN_DATABASE_COMPACT_FLAGS_MULTIPASS

Merge postlists in multiple passes

 

XAPIAN_DATABASE_COMPACT_FLAGS_SINGLE_FILE

Create a single-file database

 

Since: 1.4

Property Details

The “backend” property

  “backend”                  XapianDatabaseBackend

The backend to use when opening the database.

Flags: Read / Write / Construct Only

Default value: XAPIAN_DATABASE_BACKEND_DEFAULT

Since: 1.4


The “flags” property

  “flags”                    XapianDatabaseFlags

The flags to use when opening the database.

Flags: Read / Write / Construct Only

Since: 1.4


The “offset” property

  “offset”                   guint64

The offset inside the database file.

Flags: Read / Write / Construct Only

Default value: 0

Since: 1.4


The “path” property

  “path”                     gchar *

The path to the database directory.

Flags: Read / Write / Construct Only

Default value: NULL