Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Saller <bcsaller@objectrealms.net>2007-07-22 17:42:48 (GMT)
committer Benjamin Saller <bcsaller@objectrealms.net>2007-07-22 17:42:48 (GMT)
commit64b7f95ba456e4c2e00b9c866804b71435203e07 (patch)
treedcb7470f3b7b766576e98f84509493d95eed48cc
parentab19f19116433362051e988a9e5709018f5c4ad0 (diff)
OR style support on dicts was missing after the rewrite. Added
-rw-r--r--src/olpc/datastore/xapianindex.py5
-rw-r--r--tests/xapianindex.txt17
2 files changed, 22 insertions, 0 deletions
diff --git a/src/olpc/datastore/xapianindex.py b/src/olpc/datastore/xapianindex.py
index 3710d68..e650241 100644
--- a/src/olpc/datastore/xapianindex.py
+++ b/src/olpc/datastore/xapianindex.py
@@ -364,6 +364,11 @@ class IndexManager(object):
start = parse_timestamp_or_float(start)
end = parse_timestamp_or_float(end)
queries.append(ri.query_range(k, start, end))
+ elif isinstance(v, list):
+ # construct a set of OR queries
+ ors = []
+ for item in v: ors.append(ri.query_field(k, item))
+ queries.append(ri.query_composite(ri.OP_OR, ors))
else:
queries.append(ri.query_field(k, v))
diff --git a/tests/xapianindex.txt b/tests/xapianindex.txt
index 5638851..22aa05d 100644
--- a/tests/xapianindex.txt
+++ b/tests/xapianindex.txt
@@ -67,6 +67,23 @@ As well as quoted strings
>>> assert expect_single(im.search(r'''"Don't peek"''')).id == uid
+
+We can also issue OR styled queries over a given field by submitting
+a list of queries to a given field.
+
+>>> assert expect_single(im.search(dict(mime_type=["text/plain",
+... 'application/pdf']))).id == uid
+
+
+But an OR query for missing values still return nothing.
+
+>>> expect_none(im.search(dict(mime_type=["video/mpg",
+... 'audio/ogg'])))
+
+
+
+
+
Cleanly shut down.
>>> im.stop()