Skip to main content.
home | support | download

Back to List Archive

Bug patch for NOT operator

From: Bill Moseley <moseley(at)>
Date: Fri Dec 17 1999 - 22:57:16 GMT
I posted this as a problem on 9/30 to the list and finally got around to it
today.  I haven't had a lot of time to research the problem, but I do
believe I have a simple fix.

This bug causes the NOT operator to return incorrect and/or duplicate results.

During indexing each file is given a unique sequence number.  This is set
in the index.c countwords() function:

	if (!(filenum % 128))

Note that % 128 numbers are skipped.

For example, during indexing file numbers 127 and 129 will be used, but 128
is skipped.  

On a NOT search, swish first finds all the files that contain the search
word.  Then the function notresults() is called to invert the results list.

But during a NOT search the function notresultlist() fails to skip % 128

To continue the example, notresultlist() checks to see if file number 128
exists in the result, which it never does, and thus includes file number
128 in the (inverted) results.

Then, when swish calls lookupfile() with file number 128 it seems to return
record 129 instead.  This causes duplicates if filenum 129 is not in the
search results for the given word, or wrong results if 129 is in the results.

Sorry, I don't have a diff for patch, but it's simple.

in search.c function: notresultlist()

for (i = 1; i <= filenums; i++) {

    /* add this next line */
    if (!(i % 128) ) continue;  

    if (!ismarked(i))
        newp = (struct result *) addtoresultlist(newp, i, 1000, IN_ALL);

Bill Moseley
Received on Fri Dec 17 14:59:53 1999