Mercurial > p > roundup > code
annotate roundup/backends/indexer_rdbms.py @ 3192:eb00a2fa0e0e maint-0.8 0.8.0
pre-release stuff
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Wed, 16 Feb 2005 00:29:18 +0000 |
| parents | a7045bad20de |
| children | 2817a4db901d 3096c4b10960 |
| rev | line source |
|---|---|
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 ''' This implements the full-text indexer over two RDBMS tables. The first |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 is a mapping of words to occurance IDs. The second maps the IDs to (Class, |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 propname, itemid) instances. |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 ''' |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 import re |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
6 |
|
2872
d530b68e4b42
don't index common words [SF#1046612]
Richard Jones <richard@users.sourceforge.net>
parents:
2098
diff
changeset
|
7 from indexer_dbm import Indexer, is_stopword |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 class Indexer(Indexer): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 def __init__(self, db): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 self.db = db |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 self.reindex = 0 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
13 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 def close(self): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 '''close the indexing database''' |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 # just nuke the circular reference |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 self.db = None |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
19 def force_reindex(self): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 '''Force a reindexing of the database. This essentially |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 empties the tables ids and index and sets a flag so |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 that the databases are reindexed''' |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 self.reindex = 1 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 def should_reindex(self): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 '''returns True if the indexes need to be rebuilt''' |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 return self.reindex |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 def add_text(self, identifier, text, mime_type='text/plain'): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 ''' "identifier" is (classname, itemid, property) ''' |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
31 if mime_type != 'text/plain': |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
32 return |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 # first, find the id of the (classname, itemid, property) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 a = self.db.arg |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
36 sql = 'select _textid from __textids where _class=%s and '\ |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 '_itemid=%s and _prop=%s'%(a, a, a) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 self.db.cursor.execute(sql, identifier) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 r = self.db.cursor.fetchone() |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 if not r: |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
41 id = self.db.newid('__textids') |
|
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
42 sql = 'insert into __textids (_textid, _class, _itemid, _prop)'\ |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 ' values (%s, %s, %s, %s)'%(a, a, a, a) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 self.db.cursor.execute(sql, (id, ) + identifier) |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
45 self.db.cursor.execute('select max(_textid) from __textids') |
|
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
46 id = self.db.cursor.fetchone()[0] |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 else: |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 id = int(r[0]) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 # clear out any existing indexed values |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
50 sql = 'delete from __words where _textid=%s'%a |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 self.db.cursor.execute(sql, (id, )) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 # ok, find all the words in the text |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 wordlist = re.findall(r'\b\w{2,25}\b', str(text).upper()) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 words = {} |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 for word in wordlist: |
|
2872
d530b68e4b42
don't index common words [SF#1046612]
Richard Jones <richard@users.sourceforge.net>
parents:
2098
diff
changeset
|
57 if is_stopword(word): |
|
d530b68e4b42
don't index common words [SF#1046612]
Richard Jones <richard@users.sourceforge.net>
parents:
2098
diff
changeset
|
58 continue |
|
d530b68e4b42
don't index common words [SF#1046612]
Richard Jones <richard@users.sourceforge.net>
parents:
2098
diff
changeset
|
59 words[word] = 1 |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 words = words.keys() |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 # for each word, add an entry in the db |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 for word in words: |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 # don't dupe |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
65 sql = 'select * from __words where _word=%s and _textid=%s'%(a, a) |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 self.db.cursor.execute(sql, (word, id)) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 if self.db.cursor.fetchall(): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
68 continue |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
69 sql = 'insert into __words (_word, _textid) values (%s, %s)'%(a, a) |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 self.db.cursor.execute(sql, (word, id)) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 def find(self, wordlist): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 '''look up all the words in the wordlist. |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 If none are found return an empty dictionary |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 * more rules here |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
76 ''' |
|
3034
2739e3150e40
merge from HEAD
Richard Jones <richard@users.sourceforge.net>
parents:
2872
diff
changeset
|
77 if not wordlist: |
|
2739e3150e40
merge from HEAD
Richard Jones <richard@users.sourceforge.net>
parents:
2872
diff
changeset
|
78 return {} |
|
2739e3150e40
merge from HEAD
Richard Jones <richard@users.sourceforge.net>
parents:
2872
diff
changeset
|
79 |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 l = [word.upper() for word in wordlist if 26 > len(word) > 2] |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 |
|
3046
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
82 if not l: |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 return {} |
|
3046
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
84 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
85 if self.db.implements_intersect: |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
86 # simple AND search |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
87 sql = 'select distinct(_textid) from __words where _word=%s'%self.db.arg |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
88 sql = '\nINTERSECT\n'.join([sql]*len(l)) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
89 self.db.cursor.execute(sql, tuple(l)) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
90 r = self.db.cursor.fetchall() |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
91 if not r: |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
92 return {} |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
93 a = ','.join([self.db.arg] * len(r)) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
94 sql = 'select _class, _itemid, _prop from __textids '\ |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
95 'where _textid in (%s)'%a |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
96 self.db.cursor.execute(sql, tuple([int(id) for (id,) in r])) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
97 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
98 else: |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
99 # A more complex version for MySQL since it doesn't implement INTERSECT |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
100 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
101 # Construct SQL statement to join __words table to itself |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
102 # multiple times. |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
103 sql = """select distinct(__words1._textid) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
104 from __words as __words1 %s |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
105 where __words1._word=%s %s""" |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
106 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
107 join_tmpl = ' left join __words as __words%d using (_textid) \n' |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
108 match_tmpl = ' and __words%d._word=%s \n' |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
109 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
110 join_list = [] |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
111 match_list = [] |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
112 for n in xrange(len(l) - 1): |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
113 join_list.append(join_tmpl % (n + 2)) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
114 match_list.append(match_tmpl % (n + 2, self.db.arg)) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
115 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
116 sql = sql%(' '.join(join_list), self.db.arg, ' '.join(match_list)) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
117 self.db.cursor.execute(sql, l) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
118 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
119 r = map(lambda x: x[0], self.db.cursor.fetchall()) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
120 if not r: |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
121 return {} |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
122 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
123 a = ','.join([self.db.arg] * len(r)) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
124 sql = 'select _class, _itemid, _prop from __textids '\ |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
125 'where _textid in (%s)'%a |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
126 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
127 self.db.cursor.execute(sql, tuple(map(int, r))) |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
128 |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
129 # self.search_index has the results as {some id: identifier} ... |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
130 # sigh |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
131 r = {} |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
132 k = 0 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
133 for c,n,p in self.db.cursor.fetchall(): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
134 key = (str(c), str(n), str(p)) |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
135 r[k] = key |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
136 k += 1 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
137 return r |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
138 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
139 def save_index(self): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
140 # the normal RDBMS backend transaction mechanisms will handle this |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
141 pass |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
142 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
143 def rollback(self): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 # the normal RDBMS backend transaction mechanisms will handle this |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 pass |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 |
