Today's your lucky day (I think), because I was looking for (and used) the
aggregate function mentioned below just before reading your question.
At 11:03 AM 1/7/06, Tomas Vondra wrote:
1) How to create a "table" in the form
documtent_id | word_1 | word_2 | ... | word_n
-------------------------------------------------
1345 | 11 | 12 | ... | 2
1202 | 1 | 0 | ... | 12
. . . . .
. . . . .
1129 | 20 | 1 | ... | 0
from the query
SELECT docId, word, score FROM Index WHERE word IN (word_1,..,word_n)
From section 31.10 of the 8.0 docs came this function...
CREATE AGGREGATE array_accum (
sfunc = array_append,
basetype = anyelement,
stype = anyarray,
initcond = '{}'
);
This query will return one row per docld. It's not exactly the format you
asked for, but perhaps it's a start ...
select docld,array_accum(word),array_accum(score) from index where word in
('apples','orange') group by docld;
Then your could write two functions (beyond my capabilities):
minarray( int[] ) so you could select minarray( array_accum(score) ) /*
apples AND orange */
maxarray( int[] ) so you could select maxarray( array_accum(score) ) /*
apples OR orange */
2) How to evaluate the function derived from the 'search string' on this
table, but this probably will work as an EXECUTE statement or
something like that.
Not sure what you're asking here....
---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings