GroupDocs.Search for Java を使用した効率的なドキュメント検索のマスター

ドキュメント管理の世界では、膨大な文書の中から特定のコンテンツを迅速に見つけることが重要です。法務契約書や学術論文を管理している場合でも、create index java 機能は手作業の時間を何時間も節約できます。このチュートリアルでは、強力な java search library である GroupDocs.Search for Java の使用方法を掘り下げ、インデックスの作成、add documents to index、およびファイルからの extract text java を効率的に行う方法を紹介します。本ガイドの最後までに、カスタム設定でのインデックス設定方法や、構造化テキスト抽出を含むさまざまな形式で文書テキストを出力する方法が分かります。

クイック回答

  • 主な目的は何ですか? create index java を使用して、文書コンテンツを迅速に取得します。
  • どのライブラリを使用すべきですか? GroupDocs.Search for Java java search library を使用します。
  • テキストをファイルに出力できますか? はい、提供されている output text to file アダプタを使用してください。
  • 構造化抽出はサポートされていますか? もちろんです – structured text extraction アダプタを使用してください。
  • ライセンスは必要ですか? 本番環境で使用するには、トライアルまたは永続ライセンスが必要です。

学習内容

  • GroupDocs.Search for Java を使用して、create index javaadd documents to index を行う方法。
  • output text to file、ストリーム、文字列、構造化データのテクニック。
  • 効率的な検索とメモリ管理のためのパフォーマンス最適化のヒント。
  • これらの機能の実際の活用例。

前提条件

チュートリアルに入る前に、以下が準備されていることを確認してください。

  • Java Development Kit (JDK): バージョン8以上を推奨します。
  • GroupDocs.Search for Java ライブラリ。
  • プロジェクトの依存関係管理とビルドに Maven を使用します。
  • 特にファイル I/O 操作に関する Java プログラミングの基本知識。

GroupDocs.Search for Java の設定

GroupDocs.Search for Java を使用開始するには、プロジェクトに必要な依存関係を追加する必要があります。Maven を使用した設定方法は以下の通りです。

Maven 設定
pom.xml ファイルに以下のリポジトリと依存関係の設定を追加してください。

<repositories>
    <repository>
        <id>repository.groupdocs.com</id>
        <name>GroupDocs Repository</name>
        <url>https://releases.groupdocs.com/search/java/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-search</artifactId>
        <version>25.4</version>
    </dependency>
</dependencies>

直接ダウンロードを希望する場合は、最新バージョンを GroupDocs.Search for Java releases から取得できます。

ライセンス取得
GroupDocs.Search を使用するには、無料トライアルまたは一時ライセンスの取得を検討してください。正式に購入する場合は、公式サイトで永続ライセンスを取得してください。

カスタム設定で create index java を作成する方法

このセクションでは、インデックスの作成、文書の追加、最適なストレージのための圧縮設定方法について説明します。

インデックス作成と文書インデックス化

概要

インデックスを作成することで、文書を効率的に検索できます。以下の例は、高圧縮で create index java を行い、続いて add documents to index を実行する方法を示しています。

import com.groupdocs.search.*;
import java.io.ByteArrayOutputStream;

public class FeatureIndexCreation {
    public static void main(String[] args) {
        // Define the folder paths for indexing
        String indexFolder = YOUR_DOCUMENT_DIRECTORY + "/OutputAdapters/Index";
        String documentsFolder = YOUR_DOCUMENT_DIRECTORY + "/DocumentsPath";  // Adjust as needed

        // Creating an index settings instance with compression enabled
        IndexSettings settings = new IndexSettings();
        settings.setTextStorageSettings(new TextStorageSettings(Compression.High));

        // Creating the index in the specified folder
        Index index = new Index(indexFolder, settings);

        // Adding documents from the specified folder to the index
        index.add(documentsFolder);
    }
}

説明

  • Index Settings: テキスト保存に高圧縮を有効にし、ディスク容量の使用を最適化します。
  • Adding Documents: index.add() メソッドは adds documents to index を行い、フォルダーを再帰的にスキャンします。

テキストをファイル、ストリーム、文字列、構造化形式に出力する方法

以下は、created index java 後に抽出されたコンテンツを取得・保存する一般的な4つの方法です。

文書テキストのファイル出力

概要

この例は、HTML 形式で output text to file を行う方法を示しており、視覚的な確認やさらなる処理に便利です。

import com.groupdocs.search.*;

public class FeatureOutputToFile {
    public static void main(String[] args) {
        String indexFolder = YOUR_DOCUMENT_DIRECTORY + "/OutputAdapters/Index";
        Index index = new Index(indexFolder);

        // Assuming documents are already indexed, retrieve the first document
        DocumentInfo[] documents = index.getIndexedDocuments();
        if (documents.length > 0) {
            DocumentInfo document = documents[0];

            // Output document text to an HTML file
            FileOutputAdapter fileOutputAdapter = new FileOutputAdapter(OutputFormat.Html, YOUR_OUTPUT_DIRECTORY + "/Text.html");
            index.getDocumentText(document, fileOutputAdapter);
        }
    }
}

説明

  • FileOutputAdapter: インデックス化された文書のテキストを HTML に変換し、指定されたファイルパスに書き込みます。

文書テキストのストリーム出力

概要

メモリ内処理(動的なウェブコンテンツ生成など)が必要な場合、ストリームへの出力が最適です。

import com.groupdocs.search.*;
import java.io.ByteArrayOutputStream;

public class FeatureOutputToStream {
    public static void main(String[] args) {
        String indexFolder = YOUR_DOCUMENT_DIRECTORY + "/OutputAdapters/Index";
        Index index = new Index(indexFolder);

        // Assuming documents are already indexed, retrieve the first document
        DocumentInfo[] documents = index.getIndexedDocuments();
        if (documents.length > 0) {
            DocumentInfo document = documents[0];

            // Output document text to a stream in HTML format
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            StreamOutputAdapter streamOutputAdapter = new StreamOutputAdapter(OutputFormat.Html, stream);
            index.getDocumentText(document, streamOutputAdapter);
        }
    }
}

説明

  • StreamOutputAdapter: 文書のテキストを ByteArrayOutputStream にストリームし、ファイルシステムに触れずに柔軟に処理できます。

文書テキストの文字列出力

概要

単にログや表示が必要な場合、結果を String に変換するのが最も簡単です。

import com.groupdocs.search.*;

public class FeatureOutputToString {
    public static void main(String[] args) {
        String indexFolder = YOUR_DOCUMENT_DIRECTORY + "/OutputAdapters/Index";
        Index index = new Index(indexFolder);

        // Assuming documents are already indexed, retrieve the first document
        DocumentInfo[] documents = index.getIndexedDocuments();
        if (documents.length > 0) {
            DocumentInfo document = documents[0];

            // Output document text to a string in HTML format
            StringOutputAdapter stringOutputAdapter = new StringOutputAdapter(OutputFormat.Html);
            index.getDocumentText(document, stringOutputAdapter);
            String result = stringOutputAdapter.getResult();
        }
    }
}

説明

  • StringOutputAdapter: 文書のテキストを String に取得し、ログや UI コンポーネントに埋め込むのが容易です。

文書テキストの構造化形式出力

概要

フィールド、テーブル、カスタムメタデータの抽出など高度なパースが必要な場合は、構造化出力アダプタを使用してください。

import com.groupdocs.search.*;

public class FeatureOutputToStructure {
    public static void main(String[] args) {
        String indexFolder = YOUR_DOCUMENT_DIRECTORY + "/OutputAdapters/Index";
        Index index = new Index(indexFolder);

        // Assuming documents are already indexed, retrieve the first document
        DocumentInfo[] documents = index.getIndexedDocuments();
        if (documents.length > 0) {
            DocumentInfo document = documents[0];

            // Output document text to a structured format like PlainText
            StructuredOutputAdapter structuredOutputAdapter = new StructuredOutputAdapter(OutputFormat.PlainText);
            index.getDocumentText(document, structuredOutputAdapter);
        }
    }
}

説明

  • StructuredOutputAdapter: 文書テキストを structured text extraction 形式に抽出し、細かい分析や下流データパイプラインを可能にします。

よくある問題と解決策

問題原因対策
インデックスが作成されていませんフォルダー パスが間違っているか、書き込み権限がありませんindexFolder が存在し、アプリケーションに書き込み権限があることを確認してください
文書が返されませんindex.add() が呼び出されていない、またはソースフォルダーが間違っていますdocumentsFolder が正しいディレクトリを指し、サポートされているファイルタイプが含まれていることを確認してください
出力ファイルが空です出力アダプタのパスが無効、またはディレクトリが存在しません実行前に対象ディレクトリ (YOUR_OUTPUT_DIRECTORY) を作成してください
大きなファイルでメモリ使用量が急増ファイル全体をメモリに読み込んでいるストリームアダプタ (StreamOutputAdapter) を使用してデータを段階的に処理してください

よくある質問

Q: GroupDocs.Search を Kotlin や Scala などの他の JVM 言語で使用できますか?
A: はい、ライブラリは純粋な Java で実装されており、任意の JVM 言語とシームレスに動作します。

Q: 圧縮は検索速度にどのように影響しますか?
A: 高圧縮はディスク使用量を減らしますが、インデックス作成時に若干の CPU オーバーヘッドが発生する可能性があります。検索パフォーマンスは、ライブラリがオンザフライで解凍するため高速なままです。

Q: 既存のインデックスを再構築せずに更新できますか?
A: もちろんです。新しいファイルには index.add() を、古くなったファイルの削除には index.remove() を使用してください。

Q: さらに自然言語処理を行う場合、どの出力形式が最適ですか?
A: structured text extraction アダプタを使用した PlainText は、クリーンで言語に依存しないコンテンツを提供し、NLP パイプラインに最適です。

Q: 開発やテストにライセンスは必要ですか?
A: 開発・評価には無料トライアルライセンスで問題ありません。実運用には購入したライセンスが必要です。


最終更新: 2026-01-14
テスト環境: GroupDocs.Search 25.4 for Java
作者: GroupDocs