def indexSearchableText(self, icc):
     self._index_filename(icc, "SearchableText")
     data = self.context.getFileContent()
     if self.hasTextContent:
         encoding = chardet.detect(data)["encoding"]
         icc.addContent("SearchableText", data.decode(encoding, "ignore"))
     else:
         icc.addBinary("SearchableText", data, self.context.Format())
Exemple #2
0
 def indexSearchableText(self, icc):
     self._index_filename(icc, 'SearchableText')
     data=self.context.getFileContent()
     if self.hasTextContent:
         encoding=chardet.detect(data)["encoding"]
         icc.addContent("SearchableText",
                 data.decode(encoding, "ignore"))
     else:
         icc.addBinary("SearchableText", data, self.context.Format())
Exemple #3
0
    def SearchableText(self):
        """Return textual content of the file for the search index.
        
        This is usually only used If TextIndexNG3 is not installed.
        But if collective.solr is used then this is used even with
        TextIndexNG3.
        """
        result = BaseProxy.SearchableText(self)

        indexable = IIndexableContent(self, None)
        if indexable is not None:
            # We might get here if TextIndexNG3 is installed but
            # the content is being indexed by collective.solr.
            # In this case, use TextIndexNG3 to obtain the text for
            # binary files.
            icc = indexable.indexableContent(['SearchableText'])
            result = ' '.join(info['content'].encode('utf8')
                              for info in icc.getFieldData('SearchableText'))
        elif self.Format().startswith("text/"):
            data = self.get_data()
            encoding = chardet.detect(data)["encoding"] or 'ascii'
            result += ' ' + data.decode(encoding, 'ignore').encode('utf8')

        return result
Exemple #4
0
    def SearchableText(self):
        """Return textual content of the file for the search index.
        
        This is usually only used If TextIndexNG3 is not installed.
        But if collective.solr is used then this is used even with
        TextIndexNG3.
        """
        result = BaseProxy.SearchableText(self)

        indexable = IIndexableContent(self, None)
        if indexable is not None:
            # We might get here if TextIndexNG3 is installed but
            # the content is being indexed by collective.solr.
            # In this case, use TextIndexNG3 to obtain the text for
            # binary files.
            icc = indexable.indexableContent(['SearchableText'])
            result = ' '.join(info['content'].encode('utf8')
                              for info in icc.getFieldData('SearchableText'))
        elif self.Format().startswith("text/"):
            data = self.get_data()
            encoding = chardet.detect(data)["encoding"]
            result += ' ' + data.decode(encoding, 'ignore').encode('utf8')

        return result