muk-it / muk_dms

MuK Document Management System
GNU Lesser General Public License v3.0
91 stars 143 forks source link

[10.0] - Index Files #49

Closed Bilbonet closed 6 years ago

Bilbonet commented 6 years ago

Hello. In configuration is checked the option to index files, but I see in the DB that this field is always null, there is nothing. The searches by this field obviously don't work.

keshrath commented 6 years ago

The DMS only implements a very simple indexing of files. Only Text Files can be indexed. With the latest version this feature has been removed. We are currently working on a new module which will search and is much more powerful in indexing files.

def _compute_index(self, write=True):
        def get_index(record):
            type = record.mimetype.split('/')[0] if record.mimetype else record._compute_mimetype(write=False)['mimetype']  
            index_files = record.settings.index_files if record.settings else record.directory.settings.index_files
            if type and type.split('/')[0] == 'text' and record.content and index_files:
                words = re.findall("[^\x00-\x1F\x7F-\xFF]{4,}", base64.b64decode(record.content))
                return ustr("\n".join(words))
            else:
                return None   
        if write:
            for record in self:
                record.index_content = get_index(record)
        else:
            self.ensure_one()
            return {'index_content': get_index(self)}