We’re happy to announce the release of GroupDocs.Search for Python v26.10, available as of 2026年11月. This is the initial release of the product, bringing the full functionality of GroupDocs.Search 26.10 engine to Python developers. It enables building and maintaining full‑text indexes over folders of documents — including PDF, Word, Excel, PowerPoint, email, eBook, archive and many other formats (80+ in total) — and searching them with advanced query types: keyword, phrase, wildcard, regex, fuzzy, boolean, faceted, and date‑range searches. The release supports Python 3.5–3.14 on Windows x64, Linux x64 (glibc 2.27+), and macOS 13+ (Intel and Apple Silicon), embedding the .NET 10.0.14 runtime.
このリリースの新機能
- [機能] GroupDocs.Search for Python via .NET の初期リリース (SEARCHPYTHONNET-40)
パブリック API の変更
これは最初のリリースなので、アップグレード元はありません。API は GroupDocs.Search for .NET 26.10 に従います:クラスは .NET の名前を保持し、メソッド、プロパティ、パラメータは snake_case で記述され(Index.Search は index.search、SearchResult.DocumentCount は result.document_count)、列挙型メンバーは大文字で記述されます(OutputFormat.HTML)。クラスに存在しない属性を代入すると、エンジンが決して認識しない Python 専用属性を作成する代わりに、AttributeError が “Did you mean” ヒントとともに発生します。
モジュール
groupdocs.search:Index,IndexSettings,IndexRepository,IndexUpdater,SearchQuery,Extractor,License,Metered,GroupDocsSearchException,LicenseError,CancellationTokenSource.groupdocs.search.options:IndexingOptions,SearchOptions,FuzzySearchOptions,SimilarityLevel,UpdateOptions,HighlightOptions,OutputFormat,SeparateProcessOptions,ImageSearchOptions.groupdocs.search.results:SearchResult,FoundDocument,FoundDocumentField,DocumentInfo,FileType,FormatFamily.groupdocs.search.highlighters:DocumentHighlighter,FragmentHighlighter.groupdocs.search.common:FileOutputAdapter,StringOutputAdapter,StreamOutputAdapter,Document,DocumentField,ExtractedData,FileLogger,AttributeChangeBatch.groupdocs.search.dictionaries:SynonymDictionary,HomophoneDictionary,StopWordDictionary,SpellingCorrector,AliasDictionary,CharacterReplacementPair.groupdocs.search.events:EventHub,FileIndexingEventArgs,IndexErrorEventArgs,OperationProgressEventArgs,PasswordRequiredEventArgs.groupdocs.search.exceptions:SearchException,LicenseRestrictionException.groupdocs.search.scaling:SearchNetworkNode,Indexer,Searcher.groupdocs.search.scaling.configuring:Configuration,Configurator,TcpSettings.
新機能
ドキュメントをインデックス化して検索する
Index(folder) はフォルダー内にインデックスを作成するか、既に存在するインデックスを開きます。add() はフォルダー、ファイル、パスのリスト、ストリーム、または抽出データをインデックス化し、search() は GroupDocs.Search のクエリ言語でクエリを受け取ります:キーワード、引用符で囲んだフレーズ、ワイルドカード(1文字は ?、1〜5文字は ?(1~5))、^ の後の正規表現、AND、OR、NOT、content: Bern や filename: einstein のようなフィールドクエリ、日付や数値の範囲。SearchQuery は同様のクエリをオブジェクトとして構築します。
from groupdocs.search import Index
with Index("./index") as index: # creates the index folder, or opens it
index.add("./documents") # indexes every supported file in the folder
for query in ["relativity", '"theory of relativity"', "relativ?ty",
"^relativ.*", "Einstein AND NOT Newton", "content: Bern"]:
result = index.search(query)
print("%-26s %d documents, %d occurrences"
% (query, result.document_count, result.occurrence_count))
あいまい検索、同義語検索、語形検索
あいまい検索は入力ミスや OCR エラーを許容します。同義語、同音異義語、語形検索は組み込みの英語辞書を通じてクエリを拡張し、index.dictionaries で編集できます。また、スペルやキーボードレイアウトの補正も検索オプションとして利用可能です。
from groupdocs.search import Index
from groupdocs.search.options import SearchOptions, SimilarityLevel
with Index("./index") as index:
index.add("./documents")
fuzzy = SearchOptions()
fuzzy.fuzzy_search.enabled = True
fuzzy.fuzzy_search.fuzzy_algorithm = SimilarityLevel(0.8) # 0.0 (loose) .. 1.0 (strict)
print("relativty:", index.search("relativty").document_count,
"->", index.search("relativty", fuzzy).document_count)
synonyms = SearchOptions()
synonyms.use_synonym_search = True
print("picture:", index.search("picture").document_count,
"->", index.search("picture", synonyms).document_count)
word_forms = SearchOptions()
word_forms.use_word_forms_search = True
print("letter:", index.search("letter").document_count,
"->", index.search("letter", word_forms).document_count)
見つかった箇所をハイライトする
DocumentHighlighter は見つかった用語にマークを付けた全文書を書き出し、FragmentHighlighter はそれらの周辺部分だけを HTML またはプレーンテキストとして、ファイル、文字列、またはバイナリファイルオブジェクトに出力します。
from groupdocs.search import Index
from groupdocs.search.common import FileOutputAdapter
from groupdocs.search.highlighters import DocumentHighlighter
from groupdocs.search.options import OutputFormat
with Index("./index") as index:
index.add("./documents")
result = index.search("relativity")
if result.document_count > 0:
found = result.get_found_document(0)
adapter = FileOutputAdapter(OutputFormat.HTML, "./highlighted.html")
index.highlight(found, DocumentHighlighter(adapter))
print(found.document_info.file_path, "-> highlighted.html")
.NET イベントを Python ハンドラとして使用する
インデックスのすべてのイベントは Python イベントです:+= で購読し、-= で購読解除します。ハンドラはドキュメントをスキップしたり、属性でタグ付けしたり、パスワードを提供したりでき、インデックス作成と検索の進行状況、エラー、フェーズを追跡します。
from groupdocs.search import Index
skipped = []
def on_file_indexing(sender, args):
if args.document_full_path.endswith(".zip"):
args.skip_indexing = True # leave archives out of the index
skipped.append(args.document_full_path)
with Index("./index") as index:
index.events.file_indexing += on_file_indexing
index.add("./documents")
index.events.file_indexing -= on_file_indexing
print(len(index.get_indexed_documents()), "documents indexed,", len(skipped), "archives skipped")
エンジンの拡張ポイント用 Python オブジェクト
独自フォーマット用のカスタムテキスト抽出器、ロガー、単語分割器、語形プロバイダー、ドキュメントローダー、OCR コネクタは、エンジンがインターフェースを介して呼び出す単純な Python オブジェクトまたは関数です。
from groupdocs.search import Index, IndexSettings
class LogExtractor(object):
"""Text of .log files, which the engine does not read on its own."""
extensions = [".log"]
def get_fields(self, source): # a file path, or the engine's stream
if isinstance(source, str):
with open(source, encoding="utf-8") as f:
text = f.read()
else:
text = source.read().decode("utf-8")
return [("Content", text)]
settings = IndexSettings()
settings.custom_extractors.add(LogExtractor())
with Index("./log-index", settings) as index:
index.add("./logs")
print(index.search("quota").document_count, "log file(s) mention a quota")
インデックスを最新の状態に保つ
インデックスはフォルダーです:一度構築すれば後の実行で再度開くことができます。update() は最後の add() または update() 以降に変更されたドキュメントだけを再インデックス化し、optimize() はインデックスセグメントをマージし、delete() はパスでドキュメントを削除します。
from groupdocs.search import Index
with Index("./index") as index:
index.add("./documents")
# ... files in ./documents are added, changed or removed ...
index.update() # re-indexes only what changed
index.optimize() # merges index segments so searches stay fast
print(len(index.get_indexed_documents()), "documents in the index")
環境からのライセンス
GROUPDOCS_LIC_PATH をライセンスファイルのパスまたは URL に設定すると、エンジンへの最初の呼び出し時にライセンスが適用されます;コード内では License().set_license(path) が同様の役割を果たします。適用できないライセンスは最初の呼び出し以降 LicenseError を発生させ、評価モードにフォールバックしません。ライセンスがない場合、インデックスは最大 100 ドキュメントまでしか保持できず、検索で見つかった最初の 10 件のドキュメントしか読み取れません。
export GROUPDOCS_LIC_PATH="/path/to/GroupDocs.Search.lic"
コード例
上記の「ドキュメントをインデックス化して検索する」「あいまい検索、同義語検索、語形検索」「見つかった箇所をハイライトする」「.NET イベントを Python ハンドラとして使用する」「エンジンの拡張ポイント用 Python オブジェクト」「インデックスを最新の状態に保つ」セクションをご参照いただくと、動作するコード例が確認できます。
更新の取得方法
PyPI
- Package: groupdocs-search-net 26.10.0
- Install command:
pip install groupdocs-search-net==26.10.0
直接ダウンロード
プラットフォームに対応した wheel を GroupDocs.Search for Python via .NET 26.10 ページからダウンロードし、ファイルをインストールしてください:
- Windows x64:
pip install groupdocs_search_net-26.10.0-py3-none-win_amd64.whl - Linux x64:
pip install groupdocs_search_net-26.10.0-py3-none-manylinux_2_27_x86_64.whl - macOS Intel:
pip install groupdocs_search_net-26.10.0-py3-none-macosx_13_0_x86_64.whl - macOS Apple Silicon:
pip install groupdocs_search_net-26.10.0-py3-none-macosx_13_0_arm64.whl