Настройка распределённого поиска с сетью GroupDocs.Search Java

В современном мире, управляемом данными, configure distributed search является необходимым для обработки огромных коллекций документов при низком времени отклика. Этот учебник проведёт вас через настройку надёжной сети GroupDocs.Search for Java, показывая, как deploy search across multiple nodes, add documents to index и configure TCP settings для надёжной связи. К концу вы получите масштабируемое решение поиска, готовое к продакшн‑использованию, и чёткое понимание того, почему эта архитектура превосходит однопользовательскую настройку.

Быстрые ответы

  • What is configure distributed search? Это процесс связывания нескольких независимых поисковых узлов, чтобы они совместно индексировали и отвечали на запросы, обеспечивая более высокую пропускную способность и отказоустойчивость.
  • How many nodes are recommended? Обычно 3‑5 узлов обеспечивают хороший баланс производительности и отказоустойчивости для большинства корпоративных нагрузок.
  • Do I need a license? Да — для использования GroupDocs.Search в продакшн‑режиме требуется временная или полная лицензия.
  • Which ports should I use? Выбирайте порты, свободные на ваших серверах; в примере используются 49136‑49139, но любой открытый диапазон подходит.
  • Can I add new documents after deployment? Абсолютно — вы можете add documents to index в любое время без перезапуска сети.

Configure a distributed search architecture means linking several independent search nodes so they share indexing work and answer queries collectively. This reduces load on any single machine, improves both throughput and reliability, and provides built‑in redundancy for fault tolerance.

Зачем использовать GroupDocs.Search for Java?

GroupDocs.Search for Java delivers high‑performance indexing (up to 1 GB/s on modern hardware) and scalable architecture that supports clusters of 10+ nodes. It natively understands 50+ document formats—including PDF, DOCX, XLSX, PPTX, and email files—so you can index virtually any business content without additional converters. The built‑in TcpSettings class lets you fine‑tune latency, throughput, and keep‑alive intervals, ensuring reliable inter‑node communication even across data‑center boundaries. TcpSettings configures low‑level TCP communication parameters between nodes.

Требования

Необходимые библиотеки и зависимости

Вам понадобится GroupDocs.Search for Java версии 25.4 или новее. Убедитесь, что в вашей среде разработки установлен Java.

Требования к настройке окружения

  • Java Development Kit (JDK) 11 или новее.
  • IDE, такая как IntelliJ IDEA или Eclipse, для удобного управления проектом.

Требования к знаниям

Базовые навыки программирования на Java и общее понимание настройки сети помогут вам без проблем пройти все шаги.

Настройка GroupDocs.Search for Java

Чтобы начать, добавьте GroupDocs.Search for Java в ваш проект. Это можно сделать через Maven или загрузив библиотеку напрямую.

Maven Setup
Добавьте следующий репозиторий и конфигурацию зависимости в ваш файл 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>

Direct Download
Alternatively, download the latest version from GroupDocs.Search for Java releases.

Получение лицензии

To fully utilize GroupDocs.Search, you can obtain a temporary license or purchase one. Visit GroupDocs’s licensing page for more information on how to acquire a free trial or full license. You may also use the GroupDocs licensing page for the same purpose.

Базовая инициализация и настройка

Let’s initialize GroupDocs.Search in your Java application:

import com.groupdocs.search.*;

public class SearchSetup {
    public static void main(String[] args) {
        // Create an index in the specified folder
        Index index = new Index("YOUR_INDEX_DIRECTORY");

        // Add documents to the index
        index.add("YOUR_DOCUMENT_DIRECTORY");
    }
}

Руководство по реализации

In this section, we will walk you through configuring and deploying a search network using GroupDocs.Search for Java.

Как настроить распределённый поиск с GroupDocs.Search?

Load the network configuration, define base paths, and set TCP parameters in just a few lines of code. This direct‑answer pattern shows you the essential steps before any detailed explanation.

First, create a SearchNetworkConfig object, specify a shared base directory, and assign a distinct TCP port for each node. SearchNetworkConfig defines the settings for the distributed search cluster, such as base directory and node ports. Then, instantiate TcpSettings—the class that controls socket timeout, buffer size, and keep‑alive behavior. Finally, call NetworkManager.deploy(config) to launch the cluster. NetworkManager handles deployment and management of search nodes within the cluster.

Настройка сети

The TcpSettings class is the configuration hub for all TCP‑level communication between nodes. It lets you set connection timeout, read/write buffer sizes, and whether to use Nagle’s algorithm.

Configuration configuration = ConfiguringSearchNetwork.configure("YOUR_DOCUMENT_DIRECTORY", 49136);

Развёртывание узлов

Deploy each node by providing its unique identifier and the previously defined configuration. The deployment routine automatically registers the node with the cluster, opens the listening socket, and starts background indexing threads.

public static SearchNetworkNode[] deploy(String basePath, int basePort, Configuration configuration) {
    // Define timeouts for sending and receiving data over the network.
    int sendTimeout = 3000;
    int receiveTimeout = 3000;

    // Create and start three nodes that can run on separate servers or together.
    SearchNetworkNode node1 = new SearchNetworkNode(
        1,
        basePath + "Node1",
        new TcpSettings(basePort + 1, sendTimeout, receiveTimeout)
    );
    node1.start();

    SearchNetworkNode node2 = new SearchNetworkNode(
        2,
        basePath + "Node2",
        new TcpSettings(basePort + 2, sendTimeout, receiveTimeout)
    );
    node2.start();

    SearchNetworkNode node3 = new SearchNetworkNode(
        3,
        basePath + "Node3",
        new TcpSettings(basePort + 3, sendTimeout, receiveTimeout)
    );
    node3.start();

    // Create and configure the main configuration node.
    SearchNetworkNode node0 = new SearchNetworkNode(
        0,
        basePath + "Node0",
        new TcpSettings(basePort, sendTimeout, receiveTimeout),
        new ConsoleLogger(),
        configuration
    );

    // Add an event handler to notify when the configuration is complete.
    node0.getEvents().ConfigurationCompleted.add(new EventHandler() {
        @Override
        public void invoke(Object s, EventArgs e) {
            // Event handling logic here (e.g., logging)
        }
    });

    // Configure all nodes in the network using the main configuration node.
    node0.configureAllNodes();

    // Start the search network by launching all configured nodes.
    node0.start();

    // Return an array of all deployed nodes.
    return new SearchNetworkNode[] {node0, node1, node2, node3};
}

Распространённые проблемы и решения

  • Ошибки доступа к каталогу – Убедитесь, что базовый каталог каждого узла существует и процесс Java имеет права чтения/записи.
  • Конфликты портов – Проверьте, что выбранные порты (например, 49136‑49139) не заняты другими сервисами; вы можете выполнить netstat -an для проверки.
  • Тайм‑ауты в медленных сетях – Увеличьте TcpSettings.setConnectionTimeout(), если часто происходят разрывы соединения в средах с высокой задержкой.
  • Повреждение индекса – Регулярно делайте резервные копии папки индекса и включайте NetworkManager.enableAutoRecovery() для автоматического восстановления повреждённых шардов.

Практические применения

Deploying a distributed search network can be beneficial in various scenarios:

  1. Large‑Scale Enterprise Systems – Index millions of contracts, policies, and reports while maintaining sub‑second query responses.
  2. Content Management Platforms – Serve thousands of concurrent users searching across multimedia assets without bottlenecks.
  3. E‑commerce Websites – Accelerate product searches and faceted navigation on catalogs containing millions of SKUs.

Соображения по производительности

To keep your configure distributed search environment running efficiently:

  • Управление размером индекса – GroupDocs.Search может обрабатывать индексы более 100 GB; однако следите за дисковыми I/O и рассматривайте шардинг больших коллекций между несколькими узлами.
  • Тонкая настройка ресурсов – Применяйте флаги настройки памяти Java (-Xmx8g -Xms4g) в зависимости от нагрузки и регулируйте TcpSettings.setReadBufferSize() для сетей с высокой пропускной способностью.
  • Мониторинг состояния – Используйте встроенный NetworkHealthMonitor для отслеживания CPU, памяти и сетевой задержки каждого узла и задавайте оповещения при превышении пороговых значений.

Заключение

By following this tutorial, you’ve learned how to configure distributed search and deploy a scalable GroupDocs.Search Java network. This solution can dramatically improve the speed and reliability of your application’s search features, especially when dealing with large, heterogeneous document collections.

Следующие шаги

Explore advanced capabilities such as custom analyzers, synonym handling, and real‑time indexing to further refine your search experience. You may also integrate the network with a RESTful API layer to expose search functionality to external clients.

Призыв к действию

Start implementing this robust solution in your projects today and witness the performance boost firsthand!

Часто задаваемые вопросы

Q: What is GroupDocs.Search for Java?
A: GroupDocs.Search for Java is a high‑performance library that indexes and searches text across more than 50 document formats, providing fast, scalable full‑text search for Java applications.

Q: How do I obtain a temporary license for GroupDocs.Search?
A: Visit the GroupDocs’s licensing page to request a free trial or purchase a full license for production use.

Q: Can I add new documents after the network is deployed?
A: Yes, you can add documents to index at any time using the IndexManager.addDocument() method; the changes propagate automatically across the cluster. IndexManager.addDocument() adds a new document to the index and propagates it across the network.

Q: What are common pitfalls when configuring nodes?
A: Typical issues include mismatched base paths, port conflicts, and insufficient file‑system permissions. Double‑check each node’s configuration and ensure all directories are accessible.

Q: Does the network support real‑time indexing?
A: Absolutely. GroupDocs.Search offers real‑time indexing APIs that immediately make newly added documents searchable across all nodes without downtime.


Last Updated: 2026-06-27
Tested With: GroupDocs.Search 25.4 for Java
Author: GroupDocs

Связанные руководства