FAQ
Hello All,

Is there a way to count the number of times a query matched in a particular
document?

For example, say we created a document that had the string "cheese cheese
cheese cheese" in the field that is being searched.
I would like to know that the query "cheese" matched four times in that
particular document. Is there a way to do this?

BTW, I am new to Lucene, so if I have any misconceptions that are apparent
please feel free to correct me.

Thanks,
Ryan

Search Discussions

  • Michael McCandless at Aug 8, 2010 at 2:17 pm
    Do you need this for a single document, eg for debugging? If so,
    IndexSearcher.explain can give you these details.

    If you need it for all hits, then Lucene does not make that easy
    today, which is somewhat frustrating because this information (freq of
    occurrence of each clause matching the current hit) is being computed,
    to compute the net score; it's just not accessible.

    But this is requested fairly often, so... I just opened an issue to
    make this possible:

    https://issues.apache.org/jira/browse/LUCENE-2590

    Mike
    On Sun, Aug 8, 2010 at 12:44 AM, Ryan McV wrote:
    Hello All,

    Is there a way to count the number of times a query matched in a particular
    document?

    For example, say we created a document that had the string "cheese cheese
    cheese cheese" in the field that is being searched.
    I would like to know that the query "cheese" matched four times in that
    particular document. Is there a way to do this?

    BTW, I am new to Lucene, so if I have any misconceptions that are apparent
    please feel free to correct me.

    Thanks,
    Ryan
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org
  • Ryan McV at Aug 8, 2010 at 8:10 pm
    Thank you for your response.

    Unfortunately, I do need the frequency for all the hits. I downloaded your
    patch, and ofter applying it, It works! Thank you very much.

    How ever, I could not apply the patch using the patch command (I am on
    windows and using UnxUtils, could this be the problem). I had to go through
    and manually apply the patch. This is the error I got while attempting to
    apply it(using the --verbose option, and there was a lot of stuff in front
    of it):

    patch: **** malformed patch at line 207: rs) {

    I am using the source downlaod of 3.0.2, although I could not get the patch
    to work on the latest svn either.

    Thank you again,
    Ryan
    On Sun, Aug 8, 2010 at 10:17 AM, Michael McCandless wrote:

    Do you need this for a single document, eg for debugging? If so,
    IndexSearcher.explain can give you these details.

    If you need it for all hits, then Lucene does not make that easy
    today, which is somewhat frustrating because this information (freq of
    occurrence of each clause matching the current hit) is being computed,
    to compute the net score; it's just not accessible.

    But this is requested fairly often, so... I just opened an issue to
    make this possible:

    https://issues.apache.org/jira/browse/LUCENE-2590

    Mike
    On Sun, Aug 8, 2010 at 12:44 AM, Ryan McV wrote:
    Hello All,

    Is there a way to count the number of times a query matched in a
    particular
    document?

    For example, say we created a document that had the string "cheese cheese
    cheese cheese" in the field that is being searched.
    I would like to know that the query "cheese" matched four times in that
    particular document. Is there a way to do this?

    BTW, I am new to Lucene, so if I have any misconceptions that are apparent
    please feel free to correct me.

    Thanks,
    Ryan
    ---------------------------------------------------------------------
    To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
    For additional commands, e-mail: java-user-help@lucene.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupjava-user @
categorieslucene
postedAug 8, '10 at 4:45a
activeAug 8, '10 at 8:10p
posts3
users2
websitelucene.apache.org

2 users in discussion

Ryan McV: 2 posts Michael McCandless: 1 post

People

Translate

site design / logo © 2022 Grokbase