I'm having trouble finding information on how to identify which terms
within a document triggered a match for a query. I'd like to use this
information to highlight the terms when displaying query results to a
user, much like how gmane or google do. Is there an API for this
purpose?

P.S. - I'm not subscribed to the list so please reply to me in addition
to the list.

Thanks,
Jason T.

Search Discussions

  • Olly Betts at Dec 2, 2005 at 12:51 am

    On Thu, Dec 01, 2005 at 04:27:32PM -0800, Jason Toffaletti wrote:
    I'm having trouble finding information on how to identify which terms
    within a document triggered a match for a query. I'd like to use this
    information to highlight the terms when displaying query results to a
    user, much like how gmane or google do. Is there an API for this
    purpose?
    Yes:

    http://xapian.org/docs/apidoc/html/classXapian_1_1Enquire.html#a18

    Hmm, it seems you should really be able to call methods on an
    MSetIterator to get this information - the Enquire class isn't the most
    logical place for them. I'll have a look and see if there's a good
    reason why this is part of Enquire.

    Cheers,
    Olly
  • Jason Toffaletti at Dec 21, 2005 at 12:28 am
    I finally got around to implementing this and I ran into another issue.
    I'm using the xapian python bindings and whenever I call
    positionlist_begin on a TermIterator, I get this:

    File "/usr/lib/python2.4/site-packages/xapian.py", line 169, in
    positionlist_begin
    def positionlist_begin(*args): return
    _xapian.TermIterator_positionlist_begin(*args)
    RuntimeError: InvalidOperationError: positionlist_begin not supported

    Which is consistent with the code I see here:
    http://www.xapian.org/docs/sourcedoc/html/termlist_8h-source.html

    I don't think I can implement what I want without the positionlist. My
    document is composed of terms that come from several sources and I need
    to know the position of the term to figure out which source a term came
    from and then relay that information to the front-end which would
    highlight the term in its unmodified form.

    Is positionlist something planned for the next revision?

    Thanks,
    Jason T.
    On Fri, 2005-12-02 at 00:51 +0000, Olly Betts wrote:
    On Thu, Dec 01, 2005 at 04:27:32PM -0800, Jason Toffaletti wrote:
    I'm having trouble finding information on how to identify which terms
    within a document triggered a match for a query. I'd like to use this
    information to highlight the terms when displaying query results to a
    user, much like how gmane or google do. Is there an API for this
    purpose?
    Yes:

    http://xapian.org/docs/apidoc/html/classXapian_1_1Enquire.html#a18

    Hmm, it seems you should really be able to call methods on an
    MSetIterator to get this information - the Enquire class isn't the most
    logical place for them. I'll have a look and see if there's a good
    reason why this is part of Enquire.

    Cheers,
    Olly
  • Olly Betts at Dec 21, 2005 at 8:11 am

    On Tue, Dec 20, 2005 at 04:28:45PM -0800, Jason Toffaletti wrote:
    RuntimeError: InvalidOperationError: positionlist_begin not supported

    Which is consistent with the code I see here:
    http://www.xapian.org/docs/sourcedoc/html/termlist_8h-source.html
    That's just the default implementation in the base class. We implement
    positionlist_begin in the subclasses when appropriate (sometimes it
    isn't - for example the listed of terms ignored as stopwords is
    available from the QueryParser as a TermIterator, but there's no
    document context there so positionlist_begin() doesn't make sense
    at the conceptual level).

    But it sounds like we've missed a case where it should work. I'll
    take a look, but as a workaround you can get a positionlist from the
    database by supplying the term and document id explicitly:

    http://xapian.org/docs/apidoc/html/classXapian_1_1Database.html#a13

    For the backends we currently have, that's as efficient as getting it
    from the TermIterator would be.

    Cheers,
    Olly

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupxapian-discuss @
categoriesxapian
postedDec 2, '05 at 12:27a
activeDec 21, '05 at 8:11a
posts4
users2
websitexapian.org
irc#xapian

2 users in discussion

Olly Betts: 2 posts Jason Toffaletti: 2 posts

People

Translate

site design / logo © 2022 Grokbase