# Getting indexed documents This article explains how to get a list of indexed documents from an index, and how to get the text of indexed documents in HTML or plain text format. This page contains a description of how to get a list of indexed documents from an index, and how to get the text of indexed documents in HTML or plain text format. ## Getting indexed documents To get a list of indexed documents from an index, use the [get_indexed_documents](https://reference.groupdocs.com/search/python-net/groupdocs.search/index/get_indexed_documents/) method of the [Index](https://reference.groupdocs.com/search/python-net/groupdocs.search/index/) class. Documents with the extensions ZIP, PST, OST can also contain internal documents. To get a list of internal documents, use the [get_indexed_document_items](https://reference.groupdocs.com/search/python-net/groupdocs.search/index/get_indexed_document_items/) method of the [Index](https://reference.groupdocs.com/search/python-net/groupdocs.search/index/) class. For ZIP archives, this way you can access documents of arbitrary nesting depth. An example of obtaining a list of documents from an index is presented below. {{< tabs "example1" >}} {{< tab "Python" >}} ```python from groupdocs.search import Index # Creating an index in the specified folder index = Index("./index") # Indexing documents from the specified folder index.add("./documents") # Getting list of indexed documents documents = index.get_indexed_documents() for document in documents: print(document.file_path) items = index.get_indexed_document_items(document) # Getting list of document items for item in items: print("\t" + item.inner_path) ``` {{< /tab >}} {{< tab "documents" >}} {{< tab-text >}} The following sample files are used in this example: [documents/einstein-biography.txt](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/einstein-biography.txt), [documents/relativity-primer.txt](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/relativity-primer.txt), [documents/letters-archive.zip](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/letters-archive.zip) {{< /tab-text >}} {{< /tab >}} {{< tab "getting-indexed-documents.txt" >}} ```text documents\einstein-biography.txt documents\letters-archive.zip letters\letter-1905.txt letters\letter-1915.txt readme.txt documents\relativity-primer.txt ``` [Download full output](https://docs.groupdocs.com/search/python-net/_output_files/developer-guide/advanced-usage/searching/getting-indexed-documents/getting_indexed_documents/getting-indexed-documents.txt) {{< /tab >}} {{< /tabs >}} To get a single indexed document, use the [get_indexed_document](https://reference.groupdocs.com/search/python-net/groupdocs.search/index/get_indexed_document/) method. It takes the file path of a document indexed from a file (as returned by the [DocumentInfo.file_path](https://reference.groupdocs.com/search/python-net/groupdocs.search.results/documentinfo/file_path/) property, which is a full path) or the key of a document indexed from a stream or a structure, and returns None if there is no such document in the index. {{< tabs "example2" >}} {{< tab "Python" >}} ```python import os from groupdocs.search import Index # Creating an index in the specified folder index = Index("./index") # Indexing documents from the specified folder index.add("./documents") # Getting an indexed document by its file path document = index.get_indexed_document(os.path.abspath("./documents/einstein-biography.txt")) if document is not None: print(document.file_path + " (" + str(document.file_type) + ")") ``` {{< /tab >}} {{< tab "documents" >}} {{< tab-text >}} The following sample files are used in this example: [documents/einstein-biography.txt](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/einstein-biography.txt), [documents/relativity-primer.txt](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/relativity-primer.txt), [documents/letters-archive.zip](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/letters-archive.zip) {{< /tab-text >}} {{< /tab >}} {{< tab "getting-indexed-documents-2.txt" >}} ```text documents\einstein-biography.txt (.txt) ``` [Download full output](https://docs.groupdocs.com/search/python-net/_output_files/developer-guide/advanced-usage/searching/getting-indexed-documents/getting_indexed_documents_2/getting-indexed-documents-2.txt) {{< /tab >}} {{< /tabs >}} ## Getting text of indexed documents The text of an indexed document can be extracted from an index if the option to save the text of documents in the index was enabled. If this option was not enabled when creating an index, then when the [get_document_text](https://reference.groupdocs.com/search/python-net/groupdocs.search/index/get_document_text/) method of the [Index](https://reference.groupdocs.com/search/python-net/groupdocs.search/index/) class is called, the text of the document will be extracted from the document again. Details about saving the text of documents in an index can be found on the page [Storing text of indexed documents]({{< ref "search/python-net/developer-guide/advanced-usage/indexing/storing-text-of-indexed-documents.md" >}}). The generated text of the document is passed to an instance of a class derived from the abstract class [OutputAdapter](https://reference.groupdocs.com/search/python-net/groupdocs.search.common/outputadapter/). Details on the output adapters are presented on the page [Output adapters]({{< ref "search/python-net/developer-guide/advanced-usage/searching/output-adapters.md" >}}). After generating the text of a document into a file, this file can be opened by an Internet browser. The following example shows how to extract document text from an index. {{< tabs "example3" >}} {{< tab "Python" >}} ```python import os from groupdocs.search import Index from groupdocs.search.common import FileOutputAdapter from groupdocs.search.options import OutputFormat # Creating an index in the specified folder index = Index("./index") # Indexing documents from the specified folder index.add("./documents") # Getting list of indexed documents documents = index.get_indexed_documents() # Getting a document text if len(documents) > 0: os.makedirs("./output", exist_ok=True) output_adapter = FileOutputAdapter(OutputFormat.HTML, "./output/Text.html") index.get_document_text(documents[0], output_adapter) print("The text of", os.path.basename(documents[0].file_path), "is saved to ./output/Text.html") ``` {{< /tab >}} {{< tab "documents" >}} {{< tab-text >}} The following sample files are used in this example: [documents/einstein-biography.txt](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/einstein-biography.txt), [documents/relativity-primer.txt](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/relativity-primer.txt), [documents/letters-archive.zip](https://docs.groupdocs.com/search/python-net/_sample_files/developer-guide/advanced-usage/searching/getting-indexed-documents/documents/letters-archive.zip) {{< /tab-text >}} {{< /tab >}} {{< tab "Text.html" >}} ```text
documents\einstein-biography.txt