[Xapian-discuss] having trouble getting position lists from termtierators

Jarrod Roberson jarrod at vertigrated.com
Tue Oct 31 17:37:12 GMT 2006


I am writing some Cocoa bindings so I can create a graphical "delve" style
tool for OS X.

I have most of the basic things working off Xapian::Database.

What I am stuck on is I have TermIterator working, but I can't get any
positional information off of terms I _KNOW_ have positional information.
Here is what delve reports.

>delve -t LP:support -r 34 /index/wfs
Position List for term `LP:support', record #34: 12

here is the code I can't get to work, every term throws a
Xapian::InvalidOperationError
begin and end are pointers to copies of the begin and end iterators from
database.
Anyone have a clue what might be going on.


NSMutableArray* terms = [[NSMutableArray alloc] init];
    while (*begin != *end)
    {
        NSString* text = [[NSString alloc]
initWithUTF8String:(**begin).c_str()];

        NSMutableArray* positions = [[NSMutableArray alloc] init];
        try
        {
            Xapian::PositionIterator beginpos = begin->positionlist_begin();
            Xapian::PositionIterator endpos = begin->positionlist_end();
            while (begin != end)
            {
                NSNumber* pos = [NSNumber numberWithUnsignedInt:*beginpos];
                [positions addObject:pos];
                [pos release];
                beginpos++;
            }
        }
        catch ( const Xapian::InvalidOperationError &e )
        {
            NSLog(@"no positions for term %@", text);
        }


More information about the Xapian-discuss mailing list