Text extracted from indexed documents can be stored in an index to provide the extracted text to the user faster when the get_document_text method is called, as well as to accelerate text generation with highlighting of search results.
To specify storage parameters, use the text_storage_settings property of the IndexSettings class. The default value is None, which means that the text of the documents is not stored in the index. The setting is fixed when the index is created: it cannot be changed for an existing index.
When saving text in the index, the compression property is used to specify the compression ratio of the saved text. Compression can be normal, high, or text can be saved without compression (the Compression.NORMAL, Compression.HIGH and Compression.NONE values). The choice of compression ratio affects the final size of the index, as well as the speed of indexing. A high compression ratio reduces index size and indexing speed, and the lack of compression makes index size and indexing speed maximum. The default compression ratio is normal.
The example below demonstrates storing text in an index using the high compression ratio.
fromgroupdocs.searchimportIndex,IndexSettingsfromgroupdocs.search.optionsimportCompression,TextStorageSettings# Creating an index settings instancesettings=IndexSettings()settings.text_storage_settings=TextStorageSettings(Compression.HIGH)# Setting high compression ratio for the index text storage# Creating a new index in the specified folderindex=Index("./index",settings,True)# Indexing documentsindex.add("./documents")# Searchingresult=index.search("Einstein")print("Documents found:",result.document_count)
Along with the full-featured library, we provide a free online document search app. You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our Free Online Document Search App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.