[Xapian-discuss] Re: search result context.

Jean-Francois Dockes jean-francois.dockes at wanadoo.fr
Tue Jan 24 15:15:33 GMT 2006


Charles Brandt <lists <at> st.imul.us> writes:
> It sounds like saving the whole document to the xapian Document's data field
> would bog down the search database.  That makes sense that you would need
> the whole document for context display, I just wasn't sure if there was some
> built in function that could rebuild pieces based on the position
> information.
> 
> I'll be interested to hear if anyone else has built such a system.  If not
> maybe I'll get to it someday. :)

As I had been thinking of this for some time, I just tried it, the basic thing
is actually a few lines of code:

Xapian::TermIterator term;
for (term = db->termlist_begin(docid);term != db->termlist_end(docid); term++) {
    Xapian::PositionIterator pos;
    for (pos = db->positionlist_begin(docid, *term); 
       pos != db->positionlist_end(docid, *term); pos++) {
       if (buf.size() < *pos)
          buf.resize((*pos)+1);
       buf[(*pos)] = *term;
    }
}
for (vector<string>::iterator it = buf.begin(); it != buf.end(); it++) {
    cout << *it << " ";
}

The code is very rough, there might be several terms at the same pos, etc... I
just wanted to see what came out, and the problem is, it's not very readable. It
does seem that punctuation and capitalization are good for something finally :)
An example follows.

Regards,
J.F. Dockes

introduction bluetooth is a wireless technology for creating personal networks
operating in the 2.4 ghz unlicensed band with a range of 10 meters  networks are
usually formed ad-hoc hoc from portable devices such as cellular phones
handhelds and laptops  unlike the other popular wireless technology wi-fi fi
bluetooth offers higher level service profiles e.g g ftp-like like file servers
file pushing voice transport serial line emulation and more  the bluetooth stack
in freebsd is implemented using the netgraph framework see netgraph 4  





More information about the Xapian-discuss mailing list