Modified:
/trunk/ChangeLog
/trunk/xappy/mset_search_results.py
=======================================
--- /trunk/ChangeLog Mon Feb 22 15:15:42 2010
+++ /trunk/ChangeLog Mon Feb 22 15:38:46 2010
@@ -1,3 +1,8 @@
+Mon Feb 22 23:38:17 GMT 2010 Richard Boulton <ric...@tartarus.org>
+
+ * xappy/mset_search_results.py: Support both the old and new xapian
+ APIs for getting facet values.
+
Mon Feb 22 23:14:54 GMT 2010 Richard Boulton <ric...@tartarus.org>
* libs/get_xapian.py: Update to latest versions of xapian (now
=======================================
--- /trunk/xappy/mset_search_results.py Fri Feb 5 01:41:17 2010
+++ /trunk/xappy/mset_search_results.py Mon Feb 22 15:38:46 2010
@@ -520,15 +520,25 @@
else:
if facettype == 'float':
if hasattr(xapian, 'UnbiasedNumericRanges'):
- ranges = xapian.UnbiasedNumericRanges(
- facetspy.get_values(), desired_num_of_categories)
+ try:
+ # backwards compatibility
+ ranges = xapian.UnbiasedNumericRanges(
+ facetspy.get_values(),
desired_num_of_categories)
+ except AttributeError:
+ ranges = xapian.UnbiasedNumericRanges(
+ facetspy, desired_num_of_categories)
else:
ranges = xapian.NumericRanges(facetspy.get_values(),
desired_num_of_categories)
- values = ranges.get_ranges_as_dict()
+ values =
tuple(sorted(ranges.get_ranges_as_dict().iteritems()))
else:
- values = facetspy.get_values_as_dict()
- values = tuple(sorted(values.iteritems()))
+ try:
+ values = tuple((item.term, item.termfreq)
+ for item in facetspy.values())
+ except AttributeError:
+ # backwards compatibility
+ values = facetspy.get_values_as_dict()
+ values = tuple(sorted(values.iteritems()))
score = math.fabs(len(values) - desired_num_of_categories)
if len(values) <= 1:
score = 1000