[Checkins] SVN: Products.ZCatalog/trunk/ Fixed another issue with preserving score values, when a custom index was queried first which was neither ILimitedResultIndex aware nor return scores and a later index was of the default ZCTextIndex type.

Hano Schlichting cvs-admin at zope.org
Thu Apr 26 00:25:35 UTC 2012


Log message for revision 125294:
  Fixed another issue with preserving score values, when a custom index was queried first which was neither ILimitedResultIndex aware nor return scores and a later index was of the default ZCTextIndex type.
  

Changed:
  U   Products.ZCatalog/trunk/CHANGES.txt
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py

-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt	2012-04-25 18:59:38 UTC (rev 125293)
+++ Products.ZCatalog/trunk/CHANGES.txt	2012-04-26 00:25:31 UTC (rev 125294)
@@ -4,6 +4,9 @@
 3.0a2 (unreleased)
 ------------------
 
+- Fixed another issue with preserving score values, when a custom index was
+  queried first which was neither ILimitedResultIndex aware nor return scores,
+  and a later index was of the default ZCTextIndex type.
 
 3.0a1 (2012-04-22)
 ------------------

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py	2012-04-25 18:59:38 UTC (rev 125293)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py	2012-04-26 00:25:31 UTC (rev 125294)
@@ -538,7 +538,7 @@
                 cr.start_split(intersect_id)
                 # weightedIntersection preserves the values from any mappings
                 # we get, as some indexes don't return simple sets
-                if hasattr(rs, 'items'):
+                if hasattr(rs, 'items') or hasattr(r, 'items'):
                     _, rs = weightedIntersection(rs, r)
                 else:
                     rs = intersection(rs, r)

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py	2012-04-25 18:59:38 UTC (rev 125293)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/tests/test_catalog.py	2012-04-26 00:25:31 UTC (rev 125294)
@@ -1060,3 +1060,28 @@
         brains = cat(title='1*', true=True)
         self.assertEqual(len(brains), 4)
         self.assertEqual(brains[0].title, '111')
+
+    def test_combined_scored_search_planned(self):
+        from ..plan import Benchmark
+        from ..plan import PriorityMap
+        cat = self._make_one()
+        query = dict(title='1*', true=True)
+        plan = cat.getCatalogPlan()
+        plan_key = plan.make_key(query)
+        catalog_id = plan.get_id()
+        # plan with title first
+        PriorityMap.set_entry(catalog_id, plan_key, dict(
+            title=Benchmark(1, 1, False),
+            true=Benchmark(2, 1, False),
+            ))
+        brains = cat(query)
+        self.assertEqual(len(brains), 4)
+        self.assertEqual(brains[0].title, '111')
+        # plan with true first
+        PriorityMap.set_entry(catalog_id, plan_key, dict(
+            title=Benchmark(2, 1, False),
+            true=Benchmark(1, 1, False),
+            ))
+        brains = cat(query)
+        self.assertEqual(len(brains), 4)
+        self.assertEqual(brains[0].title, '111')



More information about the checkins mailing list