Java で GroupDocs.Search ネットワークを構成する方法 – 検索の高速化
モダンでデータ集約型のアプリケーションにおいて、GroupDocs の構成方法 を正しく行うことは、膨大なドキュメントリポジトリ全体で高速かつ関連性の高い検索結果を提供する基盤です。エンタープライズポータル、ナレッジベース、製品カタログの構築に関わらず、適切にチューニングされた GroupDocs.Search ネットワークは水平スケーリング、同義語ロジックの注入、レイテンシーの管理を可能にします。本チュートリアルでは、Java を使用して GroupDocs.Search ネットワークをセットアップ、デプロイ、微調整するためのすべての手順を解説し、インデックスへの同義語追加やノードライフサイクルの取り扱いに関する実践的なアドバイスも提供します。
クイック回答
- GroupDocs.Search ネットワークを構成する主な利点は何ですか? 分散インデックス作成とクエリ実行を可能にし、パフォーマンスとスケーラビリティを向上させます。
- サンプルを実行するのにライセンスは必要ですか? 開発には無料トライアルで動作しますが、本番環境では商用ライセンスが必要です。
- インデックスを再構築せずに同義語を追加できますか? はい—実行時に同義語辞書を使用して add synonyms to index を行います。
- 何台のノードをデプロイできますか? インフラが許す限りノードをデプロイできます。各ノードは独自のポートで実行されます。
- 必要な Java バージョンは何ですか? JDK 8 以上がサポートされており、JDK 21 まで完全に互換性があります。
GroupDocs.Search ネットワークの構成とは何ですか?
GroupDocs.Search network は、共有ドキュメントセットのインデックス作成とクエリ実行を協調的に行う JVM プロセスの集合です。マスターノードが 1 つ以上のワーカーノード(シャード)をオーケストレーションします。ネットワークは基盤ストレージを抽象化し、単一のクエリが自動的にすべてのシャードへブロードキャストされ、結果がマージされて呼び出し元に返されます。
なぜ GroupDocs.Search ネットワークを構成するのか?
GroupDocs.Search ネットワークを構成すると、scalability(スケーラビリティ)、reliability(信頼性)、**enhanced relevance(関連性の向上)**という 3 つの具体的な利点が得られます。インデックス作成負荷を最大 20 ノードに分散し、各ノードが 5 GB のシャードを処理することで、単一ノード構成に比べてインデックス作成時間を約 70 % 短縮できます。同義語辞書を追加すると、代替用語を使用したクエリのリコール率が最大 35 % 向上し、ノード冗長性によりメンテナンスウィンドウ中でも 99.9 % の稼働率が保証されます。
前提条件
- Java Development Kit (JDK) 8 – 21(任意の LTS バージョン)
- プロジェクト構築用 Maven 3.5 以上
- 基本的な Java 構文と Maven 依存関係管理に関する知識
- GroupDocs.Search for Java ライブラリへのアクセス(Maven Central または公式リリースページから入手可能)
GroupDocs.Search for Java のセットアップ
Add the repository and dependency to your Maven pom.xml:
The following XML snippet adds the GroupDocs.Search repository and library dependency.
<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>
Alternatively, download the latest version directly from GroupDocs.Search for Java リリース.
ライセンス取得
- Free Trial – コア機能を無料で試せます。
- Temporary License – 短期テスト向けにフル機能を解放します。
- Commercial License – 本番デプロイとプレミアムサポートの受領に必要です。
基本的な初期化とセットアップ
Create a simple Java class to verify the library loads correctly:
The SampleInitializer class demonstrates loading the GroupDocs.Search engine.
import com.groupdocs.search.*;
public class SearchSetup {
public static void main(String[] args) {
// Initialize the index
Index index = new Index("YOUR_INDEX_DIRECTORY");
System.out.println("GroupDocs.Search is ready to use!");
}
}
GroupDocs.Search ネットワーク構成のステップバイステップガイド
1. 検索ネットワークの構成
Define the base document folder and the starting port for node communication.
SearchNetworkConfig holds the configuration for the network nodes.
import com.groupdocs.search.dictionaries.*;
import com.groupdocs.search.scaling.configuring.*;
public class ConfigureSearchNetwork {
public static void run() {
String basePath = "YOUR_DOCUMENT_DIRECTORY/AdvancedUsage/Scaling/ManagingDictionaries/";
int basePort = 49128;
Configuration configuration = ConfiguringSearchNetwork.configure(basePath, basePort);
// Configuration details and setup logic
}
}
- basePath – 辞書(例:同義語ファイル)が格納されているディレクトリ。
- basePort – 最初のポート番号。以降のノードはこの値からインクリメントされます。
2. 検索ネットワークノードのデプロイ
Spin up multiple worker nodes that share the same configuration.
SearchNode represents an individual node in the distributed network.
import com.groupdocs.search.scaling.*;
public class DeploySearchNetworkNodes {
public static void run() {
String basePath = "YOUR_DOCUMENT_DIRECTORY/AdvancedUsage/Scaling/ManagingDictionaries/";
int basePort = 49128;
Configuration configuration = new Configuration();
SearchNetworkNode[] nodes = SearchNetworkDeployment.deploy(basePath, basePort, configuration);
// Node deployment logic
}
}
Each node runs on its own port (basePort + index) and holds a shard of the overall index, allowing parallel processing of both indexing and query execution.
3. ノードイベントの購読
Monitor health, indexing progress, and error conditions by attaching an event listener to the master node.
NetworkEventListener handles callbacks for node lifecycle events.
import com.groupdocs.search.scaling.*;
public class SubscribeToNodeEvents {
public static void run() {
SearchNetworkNode masterNode = new SearchNetworkNode();
SearchNetworkNodeEvents.subscribe(masterNode);
// Event subscription logic
}
}
Event callbacks let you react to node start/stop, indexing completion, and unexpected failures, giving you full observability over the distributed system.
4. ノードのインデクサーへの同義語追加
Enhance relevance by add synonyms to index at runtime.
SynonymDictionary allows adding synonym groups to the indexer.
import com.groupdocs.search.dictionaries.*;
import com.groupdocs.search.scaling.*;
public class AddSynonyms {
public static void run(SearchNetworkNode node) {
String[] group = { "efficitur", "tristique", "venenatis" };
boolean clearBeforeAdding = true;
Indexer indexer = node.getIndexer();
int[] indices = node.getShardIndices();
SynonymDictionary dictionary = indexer.getSynonymDictionary(indices[0]);
if (clearBeforeAdding) {
dictionary.clear();
}
dictionary.addRange(new String[][] { group });
indexer.setDictionary(dictionary);
// Synonym addition logic
}
}
- group – 同等とみなすべき用語の配列。
- clearBeforeAdding – 既存エントリを置き換えたい場合は
trueに設定。
5. インデックス作成用ディレクトリの追加
Tell the master node which folders contain the documents you want searchable.
Indexer.addDirectory registers a folder for indexing.
import com.groupdocs.search.scaling.*;
import com.groupdocs.search.examples.Utils;
public class AddDirectoriesForIndexing {
public static void run(SearchNetworkNode masterNode) {
String documentsPath = "YOUR_DOCUMENT_DIRECTORY/DocumentsPath";
IndexingDocuments.addDirectories(masterNode, documentsPath);
// Directory addition logic
}
}
The method scans the directory recursively and distributes files across shards, supporting more than 10 TB of data without loading entire files into memory.
6. ネットワーク内でのテキスト検索の実行
Execute a query across all nodes, optionally forcing exact‑match behavior.
SearchEngine.search runs the query on the network.
import com.groupdocs.search.scaling.*;
public class PerformTextSearch {
public static void run(SearchNetworkNode masterNode) {
String query = "tristique";
boolean exactMatchOnly = false;
TextSearchInNetwork.searchAll(masterNode, query, exactMatchOnly);
exactMatchOnly = true;
TextSearchInNetwork.searchAll(masterNode, query, exactMatchOnly);
// Search execution logic
}
}
Switch exactMatchOnly to true when you need strict term matching without stemming, which can improve precision for code‑search scenarios by up to 20 %.
7. ネットワークノードのクローズ
Release resources gracefully once processing is complete.
node.close() shuts down a SearchNode and frees resources.
import com.groupdocs.search.scaling.*;
public class CloseNetworkNodes {
public static void run(SearchNetworkNode[] nodes) {
for (SearchNetworkNode node : nodes) {
node.close();
// Node closure logic
}
}
}
Proper shutdown prevents memory leaks and keeps the JVM healthy, especially in long‑running services that recycle nodes during off‑peak hours.
実用的な活用例
| シナリオ | ネットワークの利点 |
|---|---|
| Enterprise Search | データセンターサーバーにインデックス作成を分散し、ペタバイト規模のコーパスでも 100 M 超のドキュメントに対してサブ秒レベルのクエリ遅延を実現します。 |
| Document Management | 同義語をインデックスに追加することで、用語が異なっていてもユーザーがドキュメントを検索でき、リコール率が最大 35 % 向上します。 |
| E‑commerce Catalog | 地域別ノードをデプロイしてローカライズされた商品検索を高速化し、平均応答時間を 250 ms から 80 ms に短縮します。 |
| Content Management | 編集者が特定ディレクトリに新しいファイルを追加してもコンテンツを検索可能に保ち、ネットワークはダウンタイムなしでインクリメンタルに再インデックスします。 |
よくある問題と解決策
- Port Conflicts – Ensure each node’s port (
basePort + index) is free; adjustbasePortif needed. - Synonym Not Applied – Verify you called
indexer.setDictionary(dictionary)after adding terms; otherwise the new synonyms won’t be considered during search. - Node Not Responding – Subscribe to events; look for
NodeFailedcallbacks to diagnose network problems. - Memory Leak on Close – Always invoke
node.close()for every deployed node; consider using a try‑with‑resources block for automatic cleanup.
よくある質問
Q: How does deploying multiple nodes improve search performance?
A: Each node indexes a shard of the data, allowing parallel processing and reducing query latency as the workload is shared across the cluster.
Q: Can I add synonyms without re‑indexing existing documents?
A: Yes, you can add synonyms to index at runtime via the synonym dictionary; the changes take effect immediately for new queries.
Q: Is subscribing to node events mandatory?
A: While not required for basic operation, event subscription gives you visibility into node health and helps you react to failures promptly.
Q: What are best practices for managing node resources?
A: Regularly close idle nodes, monitor JVM memory usage, and recycle nodes during off‑peak hours to keep resource consumption optimal.
Q: Does GroupDocs.Search support non‑text formats like PDFs or images?
A: Absolutely. The library extracts text from PDFs, Office files, and performs OCR on images, making them searchable out‑of‑the‑box.
最終更新日: 2026-07-16
テスト対象: GroupDocs.Search 25.4 for Java
作者: GroupDocs