Mercurial > p > roundup > code
annotate roundup/backends/indexer_rdbms.py @ 3337:4e6d0cac633a maint-0.8
fix handling of invalid interval input
(similar to [SF#1102165] reported for date input)
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Mon, 23 May 2005 14:10:37 +0000 |
| parents | 3096c4b10960 |
| children | b24b75f2a728 |
| 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 |
|
3333
3096c4b10960
perform word splitting in unicode for national characters support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3046
diff
changeset
|
18 |
|
2093
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 |
|
3333
3096c4b10960
perform word splitting in unicode for national characters support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3046
diff
changeset
|
54 text = unicode(text, "utf-8", "replace").upper() |
|
3096c4b10960
perform word splitting in unicode for national characters support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3046
diff
changeset
|
55 wordlist = [w.encode("utf-8", "replace") |
|
3096c4b10960
perform word splitting in unicode for national characters support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3046
diff
changeset
|
56 for w in re.findall(r'(?u)\b\w{2,25}\b', text)] |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 words = {} |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 for word in wordlist: |
|
2872
d530b68e4b42
don't index common words [SF#1046612]
Richard Jones <richard@users.sourceforge.net>
parents:
2098
diff
changeset
|
59 if is_stopword(word): |
|
d530b68e4b42
don't index common words [SF#1046612]
Richard Jones <richard@users.sourceforge.net>
parents:
2098
diff
changeset
|
60 continue |
|
d530b68e4b42
don't index common words [SF#1046612]
Richard Jones <richard@users.sourceforge.net>
parents:
2098
diff
changeset
|
61 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
|
62 words = words.keys() |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 # 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
|
65 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
|
66 # don't dupe |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 continue |
|
2098
18addf2a8596
Implemented proper datatypes in mysql and postgresql backends...
Richard Jones <richard@users.sourceforge.net>
parents:
2093
diff
changeset
|
71 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
|
72 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
|
73 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 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
|
75 '''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
|
76 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
|
77 * more rules here |
|
3333
3096c4b10960
perform word splitting in unicode for national characters support
Alexander Smishlajev <a1s@users.sourceforge.net>
parents:
3046
diff
changeset
|
78 ''' |
|
3034
2739e3150e40
merge from HEAD
Richard Jones <richard@users.sourceforge.net>
parents:
2872
diff
changeset
|
79 if not wordlist: |
|
2739e3150e40
merge from HEAD
Richard Jones <richard@users.sourceforge.net>
parents:
2872
diff
changeset
|
80 return {} |
|
2739e3150e40
merge from HEAD
Richard Jones <richard@users.sourceforge.net>
parents:
2872
diff
changeset
|
81 |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 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
|
83 |
|
3046
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
84 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
|
85 return {} |
|
3046
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
86 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
87 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
|
88 # simple AND search |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
89 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
|
90 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
|
91 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
|
92 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
|
93 if not r: |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
94 return {} |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
95 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
|
96 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
|
97 '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
|
98 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
|
99 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
100 else: |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
101 # 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
|
102 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
103 # 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
|
104 # multiple times. |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
109 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
|
110 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
|
111 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
112 join_list = [] |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
113 match_list = [] |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
114 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
|
115 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
|
116 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
|
117 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
118 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
|
119 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
|
120 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
121 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
|
122 if not r: |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
123 return {} |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
124 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
125 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
|
126 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
|
127 '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
|
128 |
|
a7045bad20de
have RDBMS full-text indexer do AND searching [SF#1055435]
Richard Jones <richard@users.sourceforge.net>
parents:
3034
diff
changeset
|
129 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
|
130 |
|
2093
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
131 # 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
|
132 # sigh |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
133 r = {} |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
134 k = 0 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
135 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
|
136 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
|
137 r[k] = key |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
138 k += 1 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
139 return r |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
140 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
141 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
|
142 # 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
|
143 pass |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 def rollback(self): |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 # 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
|
147 pass |
|
3f6024ab2c7a
That's the last of the RDBMS migration steps done! Yay!
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
148 |
