XapianMSetIterator

XapianMSetIterator — Iterate through a XapianMSet

Functions

Object Hierarchy

    GObject
    ╰── XapianMSetIterator

Description

XapianMSetIterator is a class that allows iterating through the items inside a XapianMSet.

A typical example is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// retrieve the first 10 results
XapianMSet *mset = xapian_enquire_get_mset (enquire, 0, 10, NULL);

unsigned int size = xapian_mset_get_size (mset);

XapianMSetIterator *iter = xapian_mset_get_begin (mset);

while (xapian_mset_iterator_next (iter))
  {
    g_print ("Result %u of %u: %.3f [docid=%u]",
             xapian_mset_iterator_get_rank (iter) + 1,
             size,
             xapian_mset_iterator_get_weight (iter),
             xapian_mset_iterator_get_doc_id (iter, NULL));

    XapianDocument *doc = xapian_mset_iterator_get_document (iter, NULL);

    // ... use the document
  }

Functions

xapian_mset_iterator_next ()

gboolean
xapian_mset_iterator_next (XapianMSetIterator *iter);

Advances the iter forward.

You should use the return value to check if iter is still valid after being advanced, before using the XapianMSetIterator API.

Parameters

iter

a XapianMSetIterator

 

Returns

TRUE if the iterator was advanced, and FALSE otherwise


xapian_mset_iterator_prev ()

gboolean
xapian_mset_iterator_prev (XapianMSetIterator *iter);

Advances the iter backward.

You should use the return value to check if iter is still valid after being advanced, before using the XapianMSetIterator API.

Parameters

iter

a XapianMSetIterator

 

Returns

TRUE if the iterator was advanced, and FALSE otherwise


xapian_mset_iterator_is_valid ()

gboolean
xapian_mset_iterator_is_valid (XapianMSetIterator *iter);

xapian_mset_iterator_is_valid has been deprecated since version 1.6 and should not be used in newly-written code.

The iterator is now always valid, so checks using this function can be eliminated.

Prior to 1.6, this function would check whether iter was valid. However XapianMSetIterator objects are now always valid, and this function always returns TRUE.

Parameters

iter

a XapianMSetIterator

 

Returns

TRUE


xapian_mset_iterator_is_begin ()

gboolean
xapian_mset_iterator_is_begin (XapianMSetIterator *iter);

Checks if iter is at the start of the set.

Parameters

iter

a XapianMSetIterator

 

Returns

TRUE if the iterator is at the start


xapian_mset_iterator_is_end ()

gboolean
xapian_mset_iterator_is_end (XapianMSetIterator *iter);

Checks if iter is at the end of the set.

Parameters

iter

a XapianMSetIterator

 

Returns

TRUE if the iterator is at the end


xapian_mset_iterator_get_rank ()

unsigned int
xapian_mset_iterator_get_rank (XapianMSetIterator *iter);

Retrieves the rank of the current item pointed by iter .

The rank is the position of the item in the ordered list of results. The rank starts from zero.

Parameters

iter

a XapianMSetIterator

 

Returns

the rank of the item


xapian_mset_iterator_get_weight ()

double
xapian_mset_iterator_get_weight (XapianMSetIterator *iter);

Retrieves the weight of the current item pointed by iter .

Parameters

iter

a XapianMSetIterator

 

Returns

the weight of the item


xapian_mset_iterator_get_percent ()

int
xapian_mset_iterator_get_percent (XapianMSetIterator *iter);

Retrieves the weight of the current item pointed by iter as a percentage between 0 and 100.

Parameters

iter

a XapianMSetIterator

 

Returns

the weight of the item as a percentage


xapian_mset_iterator_get_document ()

XapianDocument *
xapian_mset_iterator_get_document (XapianMSetIterator *iter,
                                   GError **error);

Retrieves the XapianDocument currently pointed by the iterator.

Parameters

iter

a XapianMSetIterator

 

error

return location for a GError

 

Returns

a XapianDocument.

[transfer none]


xapian_mset_iterator_get_doc_id ()

unsigned int
xapian_mset_iterator_get_doc_id (XapianMSetIterator *iter,
                                 GError **error);

Retrieves the id of the document currently pointed by the iterator.

Parameters

iter

a XapianMSetIterator

 

error

return location for a GError

 

Returns

a document id


xapian_mset_iterator_get_collapse_count ()

unsigned int
xapian_mset_iterator_get_collapse_count
                               (XapianMSetIterator *iter);

Retrieves the estimated number of documents that have been collapsed into the current item pointed by iter .

Parameters

iter

a XapianMSetIterator

 

Returns

the number of collapsed documents


xapian_mset_iterator_get_description ()

char *
xapian_mset_iterator_get_description (XapianMSetIterator *iter);

Retrieves a description of iter , typically used for debugging.

Parameters

iter

a XapianMSetIterator

 

Returns

a description of the iterator.

[transfer full]


xapian_mset_iterator_get_mset ()

XapianMSet *
xapian_mset_iterator_get_mset (XapianMSetIterator *iter);

Retrieves the XapianMSet that created the iter .

Parameters

iter

a XapianMSetIterator

 

Returns

a XapianMSetIterator.

[transfer none]

Types and Values