Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
5fd67b93
Commit
5fd67b93
authored
Jul 15, 2012
by
Clément Schreiner
Browse files
Add a AND_NOT subquery.
parent
19ddbeb2
Changes
1
Hide whitespace changes
Inline
Side-by-side
debexpo/lib/axi.py
View file @
5fd67b93
...
...
@@ -46,6 +46,7 @@ class XapianQuery(object):
self
.
stemmer
=
xapian
.
Stem
(
"english"
)
self
.
terms
=
[]
self
.
not_terms
=
[]
@
classmethod
def
tokenize
(
cls
,
text
):
...
...
@@ -79,12 +80,20 @@ class XapianQuery(object):
for
tag
in
tags
:
self
.
terms
.
append
(
'XT'
+
tag
)
def
add_not
(
self
,
*
terms
):
"""
Add terms that should be added to the query as a AND_NOT subquery.
"""
self
.
not_terms
.
extend
(
terms
)
def
query
(
self
):
"""
Actually performs the query and return the results as a
generator.
"""
query
=
xapian
.
Query
(
xapian
.
Query
.
OP_OR
,
self
.
terms
)
query
=
xapian
.
Query
(
xapian
.
Query
.
OP_AND_NOT
,
xapian
.
Query
(
xapian
.
Query
.
OP_OR
,
self
.
terms
),
xapian
.
Query
(
xapian
.
Query
.
OP_OR
,
self
.
not_terms
))
enquire
=
xapian
.
Enquire
(
self
.
db
)
enquire
.
set_query
(
query
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment