From 64b7f95ba456e4c2e00b9c866804b71435203e07 Mon Sep 17 00:00:00 2001 From: Benjamin Saller Date: Sun, 22 Jul 2007 17:42:48 +0000 Subject: OR style support on dicts was missing after the rewrite. Added --- 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() -- cgit v0.9.1