GroupDocs.Search for Python via .NET Overview

What is GroupDocs.Search?

GroupDocs.Search for Python via .NET is a native Python library for full-text search across documents of more than 80 formats. It extracts the text and metadata of PDF, Word, Excel, PowerPoint, OpenDocument, email, eBook, archive and image files into an index on your own disk, so that a search over thousands of documents takes moments. It runs entirely on-premise, requires no Microsoft Office installation, and ships as a pre-built wheel for Windows, Linux, and macOS.

Typical uses include:

  • Search inside an application - let users find documents by their content, with queries that tolerate typos and know synonyms.
  • Retrieval for AI pipelines - find the documents and the passages an LLM needs, locally; see AI agents and LLM integration.
  • E-discovery and compliance - find every document that mentions a name or a contract number, or that matches a pattern such as a date or an account number.
  • Archive and knowledge-base search - index mail archives, ZIP files and the text of scans, and keep the index current as files are added, changed and deleted.
  • Image search - find the documents that contain a given picture with reverse image search.

Key Capabilities

CapabilityDescription
IndexingCreate an index in a folder or in memory, add files, folders and streams, and update it with only the documents that changed.
Search typesKeyword, phrase, wildcard, regular-expression and boolean queries, and faceted, date range and numeric range search.
Flexible matchingFuzzy, synonym, homophone and word-form search, spell checking and keyboard layout correction.
HighlightingMark the found words in the whole document or in fragments, as HTML or plain text.
Search resultsFound documents, occurrences and found fields, search reports and search by chunks.
Index maintenanceMerge, optimize and check indexes, delete documents, and update an index made by an older version.
DictionariesSynonyms, homophones, stop words, aliases, document passwords and more, read and changed from Python.
EventsFollow indexing and search with handlers such as index.events.file_indexing += handler, skip documents, and supply passwords as documents need them.
Python callbacksWrite text extractors, OCR connectors, loggers and word form providers as plain Python classes or functions.
ImagesReverse image search, and the text of images through an OCR engine you connect.
ScalingA search network of shards that shares indexing and search across nodes.
On-premiseNo cloud calls, no Microsoft Office install, no network traffic.

Quick Example

Index a folder of documents in different formats and search it with just a few lines of code:

import os

from groupdocs.search import Index

def quick_example():
    # Create an index in the "index" folder, or open the one already there
    with Index("./index") as index:
        # Index every supported document in the "documents" folder
        index.add("./documents")

        # Search the index and list the documents found
        result = index.search("relativity")
        print("Documents found:", result.document_count)
        # Most relevant first: the result lists the documents in the order they were indexed
        for document in sorted(result, key=lambda found: found.relevance, reverse=True):
            print(os.path.basename(document.document_info.file_path), "-", document.occurrence_count, "occurrences")

if __name__ == "__main__":
    quick_example()
Documents found: 2
relativity-notes.pdf - 5 occurrences
relativity-guide.epub - 5 occurrences

Download full output

For a query with a typo, turn on fuzzy search:

import os

from groupdocs.search import Index
from groupdocs.search.options import SearchOptions

def search_with_options():
    with Index("./index") as index:
        index.add("./documents")

        # Fuzzy search also finds words that differ from the query by a few characters
        options = SearchOptions()
        options.fuzzy_search.enabled = True

        result = index.search("Einstien", options)
        print("Documents found:", result.document_count)
        for document in sorted(result, key=lambda found: found.relevance, reverse=True):
            print(os.path.basename(document.document_info.file_path), "-", document.occurrence_count, "occurrences")

if __name__ == "__main__":
    search_with_options()
Documents found: 4
einstein-summary.html - 2 occurrences
relativity-notes.pdf - 2 occurrences
einstein-biography.docx - 2 occurrences
nobel-prize-1921.txt - 2 occurrences

Download full output

Where to next

  1. Install the package - Installation walks through installing the wheel on Windows, Linux, and macOS.
  2. Run your first search - the Quick Start Guide indexes and searches a folder of documents in five minutes.
  3. Explore the examples - How to Run Examples clones the runnable repository and runs every documented scenario locally or in Docker.
  4. Use it in depth - the Developer Guide covers indexing, every search type, highlighting, dictionaries, events and search networks.
  5. Licensing - Licensing and evaluation explains the evaluation limits and how to apply a license.
Close
Loading

Analyzing your prompt, please hold on...

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