示例#1
0
    def createCatalog(self):
        """Create a catalog for EventClassRecord searching"""
        from Products.ZCatalog.ZCatalog import manage_addZCatalog

        # XXX update to use ManagableIndex
        manage_addZCatalog(self, self.default_catalog, self.default_catalog)
        zcat = self._getOb(self.default_catalog)
        cat = zcat._catalog
        cat.addIndex('productKeys',
                     makeCaseSensitiveKeywordIndex('productKeys'))
        cat.addIndex('meta_type', makeCaseInsensitiveFieldIndex('meta_type'))
        cat.addIndex('getManufacturerName',
                     makeCaseInsensitiveFieldIndex('getManufacturerName'))
        cat.addIndex('isOS', FieldIndex('isOS'))
        zcat.addColumn('getPrimaryId')
        zcat.addColumn('id')
示例#2
0
    def cutover(self, dmd):
        manufacturers = dmd.getDmdRoot('Manufacturers')
        zcat = manufacturers.productSearch
        cat = zcat._catalog
        try:
            cat.addIndex('getManufacturerName',
                         makeCaseInsensitiveFieldIndex('getManufacturerName'))
            cat.addIndex('meta_type',
                         makeCaseInsensitiveFieldIndex('meta_type'))
            cat.addIndex('isOS', FieldIndex('isOS'))

            zcat.addColumn('id')

            log.info("Reindexing products. This may take some time...")
            manufacturers.reIndex()
        except CatalogError:
            pass
示例#3
0
def makeCaseSensitiveFieldIndex(indexName):
    index = FieldIndex(indexName)
    index.TermType = 'ustring'
    return index
示例#4
0
def makeCaseInsensitiveFieldIndex(indexName, termType='ustring'):
    index = FieldIndex(indexName)
    index.PrenormalizeTerm = 'value/lower'
    index.TermType = termType
    return index
示例#5
0
def makeCaseSensitiveFieldIndex(indexName):
    index = FieldIndex(indexName)
    index.TermType = 'ustring'
    return index
示例#6
0
def makeCaseInsensitiveFieldIndex(indexName, termType='ustring'):
    index = FieldIndex(indexName)
    index.PrenormalizeTerm = 'value/lower'
    index.TermType = termType
    return index