Skip to content

Commit adfffd6

Browse files
Bernhard ReiterBernhard Reiter
authored andcommitted
Xapian indexing improved:
Slightly faster and slightly smaller database. Closes issue2550687. Thanks to Olly Betts for the patch.
1 parent 9b5b3b4 commit adfffd6

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ Entries without name were done by Richard Jones.
55

66
2011-XX-XX 1.4.19 (r46XX)
77

8+
Features:
9+
10+
- Xapian indexing improved: Slightly faster and slightly smaller database.
11+
Closes issue2550687. Thanks to Olly Betts for the patch. (Bernhard Reiter)
12+
813
Fixed:
914

1015
- Updated the url to point to www.roundup-tracker.org in two places in the

roundup/backends/indexer_xapian.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,10 @@ def add_text(self, identifier, text, mime_type='text/plain'):
7272
# indexed so we know what we're matching when we get results
7373
identifier = '%s:%s:%s'%identifier
7474

75-
# see if the id is in the database
76-
enquire = xapian.Enquire(database)
77-
query = xapian.Query(xapian.Query.OP_AND, [identifier])
78-
enquire.set_query(query)
79-
matches = enquire.get_mset(0, 10)
80-
if len(matches):
81-
docid = matches[0].docid
82-
else:
83-
docid = None
84-
8575
# create the new document
8676
doc = xapian.Document()
8777
doc.set_data(identifier)
88-
doc.add_posting(identifier, 0)
78+
doc.add_term(identifier, 0)
8979

9080
for match in re.finditer(r'\b\w{%d,%d}\b'
9181
% (self.minlength, self.maxlength),
@@ -95,10 +85,8 @@ def add_text(self, identifier, text, mime_type='text/plain'):
9585
continue
9686
term = stemmer(word)
9787
doc.add_posting(term, match.start(0))
98-
if docid:
99-
database.replace_document(docid, doc)
100-
else:
101-
database.add_document(doc)
88+
89+
database.replace_document(identifier, doc)
10290

10391
def find(self, wordlist):
10492
'''look up all the words in the wordlist.

0 commit comments

Comments
 (0)