Indexing metadata of documents

GroupDocs.Search allows creating a full-text index or a metadata index of documents. To index only metadata without the main content of documents, set the index_type property of the index settings to IndexType.METADATA_INDEX when creating an index. The size of an index of this type will be very small. The index type is fixed when the index is created, so it cannot be changed for an existing index.

The following example demonstrates the creation of the metadata index.

from groupdocs.search import Index, IndexSettings
from groupdocs.search.options import IndexType

# Creating an instance of index settings
settings = IndexSettings()
settings.index_type = IndexType.METADATA_INDEX  # Setting index type

# Creating a new index in the specified folder
index = Index("./index", settings, True)

# Indexing documents from the specified folder
index.add("./documents")

# Searching in the index
result = index.search("Einstein")
print("Documents found:", result.document_count)

The following sample files are used in this example: documents/Lecture.docx, documents/Biography.docx

Documents found: 1

Download full output

More resources

GitHub examples

You may find more code examples in our GitHub repository:

Free online document search App

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.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.