You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2005/02/27 04:52:34 UTC
svn commit: r155613 - in incubator/lucene4c/trunk: src/search/scorer.c
test/search/scorer_test.c
Author: rooneg
Date: Sat Feb 26 19:52:32 2005
New Revision: 155613
URL: http://svn.apache.org/viewcvs?view=rev&rev=155613
Log:
Fix a problem where we were returning EOF one document too soon when
iterating over results from a boolean scorer.
* src/search/scorer.c
(boolean_scorer_find_doc): advance to the next doc before reading the
current doc, not after, and only on the second and later times through
this code.
* test/search/scorer_test.c
(test_boolean_scorer): add in a test for a boolean scorer with only a
single must query, which provides a nice test case for the early EOF
problem.
Modified:
incubator/lucene4c/trunk/src/search/scorer.c
incubator/lucene4c/trunk/test/search/scorer_test.c
Modified: incubator/lucene4c/trunk/src/search/scorer.c
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/search/scorer.c?view=diff&r1=155612&r2=155613
==============================================================================
--- incubator/lucene4c/trunk/src/search/scorer.c (original)
+++ incubator/lucene4c/trunk/src/search/scorer.c Sat Feb 26 19:52:32 2005
@@ -81,14 +81,16 @@
lcn_boolean_t got_a_hit = TRUE;
int i;
- *doc = lcn_scorer_doc (APR_ARRAY_IDX (bsb->must, 0, lcn_scorer_t *));
+ /* *doc will only be zero on the first time through, since the
+ * lowest valid document number is one. if it isn't the first
+ * time through we need to move along to the next document. */
- /* XXX make sure that calling lcn_scorer_next isn't making us bail
- * without checking the final doc in the scorer... */
+ if (*doc != 0)
+ LCN_ERR (lcn_scorer_next (APR_ARRAY_IDX (bsb->must,
+ 0,
+ lcn_scorer_t *)));
- LCN_ERR (lcn_scorer_next (APR_ARRAY_IDX (bsb->must,
- 0,
- lcn_scorer_t *)));
+ *doc = lcn_scorer_doc (APR_ARRAY_IDX (bsb->must, 0, lcn_scorer_t *));
for (i = 1; i < bsb->must->nelts; ++i)
{
Modified: incubator/lucene4c/trunk/test/search/scorer_test.c
URL: http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/test/search/scorer_test.c?view=diff&r1=155612&r2=155613
==============================================================================
--- incubator/lucene4c/trunk/test/search/scorer_test.c (original)
+++ incubator/lucene4c/trunk/test/search/scorer_test.c Sat Feb 26 19:52:32 2005
@@ -93,7 +93,24 @@
CHK_ERR (lcn_boolean_query_add (query, tquery, LCN_MUST));
- /* XXX test this point, should be identical to just using the term query. */
+ /* at this point results should be identical to just using the term query. */
+ CHK_ERR (lcn_query_scorer (&scorer, query, index, p));
+
+ ABTS_INT_EQUAL (tc, 1, lcn_scorer_doc (scorer));
+
+ while ((err = lcn_scorer_next (scorer)) == LCN_NO_ERROR)
+ {
+ if (++count == 1)
+ {
+ ABTS_INT_EQUAL (tc, 4, lcn_scorer_doc (scorer));
+ }
+ }
+
+ ABTS_INT_EQUAL (tc, APR_EOF, err->apr_err);
+
+ ABTS_INT_EQUAL (tc, 75, count);
+
+ count = 0;
CHK_ERR (lcn_term_query_create (&tquery,
lcn_term_create_cstring ("cutting",