Skip to content

Commit

Permalink
Fix indexed_attr logic and type of record keys of BooleanIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
andbag committed Aug 24, 2016
1 parent 66c2e3f commit fbe9f8a
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/Products/PluginIndexes/CompositeIndex/CompositeIndex.py
Expand Up @@ -11,7 +11,6 @@
#
##############################################################################

import sys
import logging
import time
import transaction
Expand All @@ -35,8 +34,6 @@
from itertools import product
from itertools import combinations

_marker = []

LOG = logging.getLogger('CompositeIndex')

QUERY_OPTIONS = {'FieldIndex': ('query', 'range', 'not'),
Expand Down Expand Up @@ -188,17 +185,6 @@ def __init__(self, id, ignore_ex=None, call_methods=None,
self.clear()

def _index_object(self, documentId, obj, threshold=None, attr=''):
""" index an object 'obj' with integer id 'i'
Ideally, we've been passed a sequence of some sort that we
can iterate over. If however, we haven't, we should do something
useful with the results. In the case of a string, this means
indexing the entire string as a keyword."""

# First we need to see if there's anything interesting to look at
# self.id is the name of the index, which is also the name of the
# attribute we're interested in. If the attribute is callable,
# we'll do so.

# get permuted keywords
newKeywords = self._get_permuted_keywords(obj)
Expand Down Expand Up @@ -264,9 +250,13 @@ def _get_permuted_keywords(self, obj):
def _get_component_keywords(self, obj, component):

if component.meta_type == 'FieldIndex':
# last attribute is the winner
attr = component.attributes[-1]
datum = self._get_object_datum(obj, attr)
# last attribute is the winner if value is not None
for attr in component.attributes:
datum = self._get_object_datum(obj, attr)
if datum is None:
continue
if datum is None:
return ()
if isinstance(datum, list):
datum = tuple(datum)
return (datum,)
Expand Down Expand Up @@ -350,6 +340,10 @@ def make_query(self, query):
if rec.keys is None:
continue

# convert rec keys to int for BooleanIndex
if c.meta_type == 'BooleanIndex':
rec.keys = [int(bool(v)) for v in rec.keys[:]]

c_records.append((c.id, rec))

# return if less than MIN_COMPONENTS query attributes were catched
Expand Down

0 comments on commit fbe9f8a

Please sign in to comment.