XapianWritableDatabase

XapianWritableDatabase — A writable database

Functions

Properties

XapianDatabaseAction action Read / Write / Construct Only

Types and Values

Object Hierarchy

    GEnum
    ╰── XapianDatabaseAction
    GObject
    ╰── XapianDatabase
        ╰── XapianWritableDatabase

Description

XapianWritableDatabase is a XapianDatabase sub-class that can be written to.

Functions

xapian_writable_database_new ()

XapianWritableDatabase *
xapian_writable_database_new (const char *path,
                              XapianDatabaseAction action,
                              GError **error);

Creates and initialises a XapianWritableDatabase for the given path .

If the initialization was not successful, this function returns NULL and sets error .

Parameters

path

the path of the database.

[not nullable]

action

the action to perform

 

error

return location for a GError

 

Returns

the newly created XapianWritableDatabase instance.

[transfer full]


xapian_writable_database_new_with_backend ()

XapianWritableDatabase *
xapian_writable_database_new_with_backend
                               (const char *path,
                                XapianDatabaseAction action,
                                XapianDatabaseBackend backend,
                                GError **error);

Creates and initialises a XapianWritableDatabase for the given path .

If the initialization was not successful, this function returns NULL and sets error .

Parameters

path

the path of the database.

[not nullable]

action

the action to perform

 

backend

the backend to use

 

error

return location for a GError

 

Returns

the newly created XapianWritableDatabase instance.

[transfer full]


xapian_writable_database_new_full ()

XapianWritableDatabase *
xapian_writable_database_new_full (const char *path,
                                   XapianDatabaseAction action,
                                   XapianDatabaseBackend backend,
                                   XapianDatabaseFlags flags,
                                   GError **error);

Creates and initialises a XapianWritableDatabase for the given path .

If the initialization was not successful, this function returns NULL and sets error .

Parameters

path

the path of the database.

[not nullable]

action

the action to perform

 

backend

the backend to use

 

flags

flags to be used when opening the database

 

error

return location for a GError

 

Returns

the newly created XapianWritableDatabase instance.

[transfer full]


xapian_writable_database_commit ()

gboolean
xapian_writable_database_commit (XapianWritableDatabase *self,
                                 GError **error);

Commits the pending changes of the database.

Parameters

self

a XapianWritableDatabase

 

error

return location for a GError

 

Returns

TRUE if the commit was successful


xapian_writable_database_set_metadata ()

void
xapian_writable_database_set_metadata (XapianWritableDatabase *self,
                                       const char *key,
                                       const char *value);

Set the user-specified metadata associated with a given key.

This method sets the metadata value associated with a given key. If there is already a metadata value stored in the database with the same key, the old value is replaced. If you want to delete an existing item of metadata, just set its value to the empty string.

Parameters

self

a XapianWritableDatabase

 

key

A key in the database's metadata

 

value

The value to set for key

 

Since: 1.4


xapian_writable_database_begin_transaction ()

gboolean
xapian_writable_database_begin_transaction
                               (XapianWritableDatabase *self,
                                gboolean flushed,
                                GError **error);

Begins a transaction in the database.

See also: xapian_writable_database_commit_transaction(), xapian_writable_database_cancel_transaction()

Parameters

self

a XapianWritableDatabase

 

flushed

whether the transaction should be permanently stored in the database when committed, or if the transaction should only be applied to the database

 

error

return location for a GError

 

Returns

TRUE if the transaction can be started, and FALSE if the backend does not support transactions or if a transaction is already in progress


xapian_writable_database_commit_transaction ()

gboolean
xapian_writable_database_commit_transaction
                               (XapianWritableDatabase *self,
                                GError **error);

Commits the currently pending transaction.

If the transaction was started by passing TRUE to the flushed argument of xapian_writable_database_begin_transaction() then all the changes caused by the transaction will be permanently stored inside the database.

In case of error, this function will return FALSE and set error .

Parameters

self

a XapianWritableDatabase

 

error

return location for a GError

 

Returns

TRUE if the transaction was successfully committed.


xapian_writable_database_cancel_transaction ()

gboolean
xapian_writable_database_cancel_transaction
                               (XapianWritableDatabase *self,
                                GError **error);

Cancels the currently pending transaction.

Parameters

self

a XapianWritableDatabase

 

error

return location for a GError

 

Returns

TRUE if the transaction was successfully cancelled


xapian_writable_database_add_document ()

gboolean
xapian_writable_database_add_document (XapianWritableDatabase *self,
                                       XapianDocument *document,
                                       unsigned int *docid_out,
                                       GError **error);

Adds document to a database.

Parameters

self

a XapianWritableDatabase

 

document

a XapianDocument to add

 

docid_out

return location for the id of the newly added document.

[out]

error

return location for a GError

 

Returns

TRUE if the document was added, and FALSE on error


xapian_writable_database_delete_document ()

gboolean
xapian_writable_database_delete_document
                               (XapianWritableDatabase *self,
                                unsigned int docid,
                                GError **error);

Deletes the document with the given docid from a database.

Parameters

self

a XapianWritableDatabase

 

docid

the document to delete

 

error

return location for a GError

 

Returns

TRUE if the document was successfully deleted


xapian_writable_database_replace_document ()

gboolean
xapian_writable_database_replace_document
                               (XapianWritableDatabase *self,
                                unsigned int docid,
                                XapianDocument *document,
                                GError **error);

Replaces the XapianDocument with docid inside a XapianWritableDatabase with the given document .

Parameters

self

a XapianWritableDatabase

 

docid

the id of the document to replace

 

document

a XapianDocument

 

error

return location for a GError

 

Returns

TRUE if the document was replaced


xapian_writable_database_add_spelling ()

void
xapian_writable_database_add_spelling (XapianWritableDatabase *self,
                                       const char *word);

Add a word to the spelling dictionary with a default frequency increase of 1.

If the word is already present, its frequency is increased.

Parameters

self

a XapianWritableDatabase

 

word

The word to add

 

Since: 1.2


xapian_writable_database_add_spelling_full ()

void
xapian_writable_database_add_spelling_full
                               (XapianWritableDatabase *self,
                                const char *word,
                                unsigned int freqinc);

Add a word to the spelling dictionary.

If the word is already present, its frequency is increased.

Parameters

self

a XapianWritableDatabase

 

word

The word to add

 

freqinc

How much to increase its frequency by

 

Since: 1.2


xapian_writable_database_remove_spelling ()

void
xapian_writable_database_remove_spelling
                               (XapianWritableDatabase *self,
                                const char *word);

Remove a word from the spelling dictionary.

The word's frequency is decreased by 1, and if would become zero or less then the word is removed completely.

Parameters

self

a XapianWritableDatabase

 

word

The word to remove

 

Since: 1.2


xapian_writable_database_remove_spelling_full ()

void
xapian_writable_database_remove_spelling_full
                               (XapianWritableDatabase *self,
                                const char *word,
                                unsigned int freqdec);

Remove a word from the spelling dictionary.

The word's frequency is decreased, and if would become zero or less then the word is removed completely.

Parameters

self

a XapianWritableDatabase

 

word

The word to remove

 

freqdec

How much to decrease its frequency by

 

Since: 1.2

Types and Values

enum XapianDatabaseAction

Actions for XapianWritableDatabase.

Members

XAPIAN_DATABASE_ACTION_CREATE_OR_OPEN

Create a database or open if it already exists

 

XAPIAN_DATABASE_ACTION_CREATE_OR_OVERWRITE

Create a database and overwrite it if one already exists

 

XAPIAN_DATABASE_ACTION_CREATE

Create a database

 

XAPIAN_DATABASE_ACTION_OPEN

Open a database

 

Property Details

The “action” property

  “action”                   XapianDatabaseAction

The action to be performed when creating a database.

Flags: Read / Write / Construct Only

Default value: XAPIAN_DATABASE_ACTION_CREATE_OR_OPEN