fromgroupdocs.searchimportIndex,IndexSettingsfromgroupdocs.search.commonimportDocumentField# A custom extractor: the extensions it handles, and the fields it extractsclassLogExtractor(object):extensions=[".log"]defget_fields(self,source):# source is a file path, or a binary stream for a document added from a streamifisinstance(source,str):withopen(source,encoding="utf-8-sig")asf:text=f.read()else:text=source.read().decode("utf-8-sig")return[DocumentField("Content",text)]# Using the custom extractor for indexingsettings=IndexSettings()settings.custom_extractors.add(LogExtractor())index=Index("./MyIndex",settings)# Create or load an indexindex.add("./documents")# Index documents