Skip to content

MongoDB Index Action

This component helps you manage search indexes within your MongoDB database directly from your Nappai workflow. Indexes act like book indexes, making it much faster for your database to find and retrieve specific information. You can use this component to view existing indexes, create new ones for faster searches, or remove them when they are no longer needed. The component handles the secure connection to your database automatically and returns the results directly to your workflow for further use.

How it Works

When you connect this component to your MongoDB database, it acts as a smart assistant that organizes how your data is stored and searched. Instead of manually writing complex database commands, you simply select the operation you need (like viewing, creating, or deleting an index) and provide the necessary details. The component securely communicates with your MongoDB instance, performs the requested task, and sends back a clear result. This makes it easy to optimize your data structure without needing to understand backend database commands.

Connection & Credentials

This component requires configuring a credential in the Nappai panel before interacting with the external service:

  1. Go to the Credentials section in your Nappai panel.
  2. Create a new credential of the type MongoDB Connection and fill in the required fields (API Keys, tokens, etc.).
  3. In your workflow, select the saved credential in the Credential input field of this node.

Inputs

Input Fields

The following fields are available to configure this component. Each field may be visible in different operations:

  • Database Name: The name of the database where your target collection is stored.
    • Visible in: All operations
  • Collection Name: The specific collection (table) where you want to manage search indexes.
    • Visible in: All operations
  • Operation: Choose what you want to do: view existing indexes, create a new one, or delete an index.
    • Visible in: All operations
  • Index Type: Select the type of index: ‘search’ for standard full-text search or ‘vectorSearch’ for advanced vector similarity search.
    • Visible in: create a new one
  • Index Name: A unique, descriptive name for your index (e.g., ‘product_vector_index’ or ‘text_search_idx’).
    • Visible in: create a new one, delete an index
  • Index Definition: A JSON object that defines the structure and field mappings for your index. Must be provided as a valid JSON string.
    • Visible in: create a new one

Outputs

The component delivers structured results that you can use to move your workflow forward or verify that a task completed successfully.

  • Data: Returns the detailed information about the requested indexes. Depending on your operation, this will show a list of existing index configurations, or a confirmation message with performance details for newly created or deleted indexes.

Output Data Example (JSON)json

{ “indexes”: [ { “name”: “product_search_idx”, “type”: “search”, “fields”: [ { “path”: “product_name”, “type”: “string” } ], “status”: “available” } ], “total_found”: 1, “operation_result”: “success” }

Connectivity

This component is typically placed after a MongoDB Connection credential node and before data processing, reporting, or AI task nodes.

  • Incoming: It receives security and connection details from your saved MongoDB credential. It also requires a database name and collection name, which usually come from a data collection node or a static text input.
  • Outgoing: The Data output feeds naturally into Data Processing, AI Assistant, or Reporting nodes. For example, you can map the index details to an AI node to generate a summary of your database’s search capabilities, or use the success status to trigger follow-up automation steps.

Usage Example

Imagine you are building an automated reporting workflow for an e-commerce platform. You have a large collection of product records and want to ensure that text searches (like looking up products by name or description) run instantly.

  1. Connect the MongoDB Connection credential to this node.
  2. Set Database Name to ecommerce_db and Collection Name to products.
  3. Select Operation as create a new one.
  4. Set Index Type to search, provide an Index Name like product_text_search, and paste a simple JSON definition for Index Definition.
  5. When the workflow runs, the component creates the index. The Data output confirms the creation, and you can connect it to a notification node to alert your team that the database is now optimized.

Tips and Best Practices

  • Always use clear, descriptive names for your indexes to make it easier to track and manage them later.
  • Only create indexes for fields you frequently search or filter by; unnecessary indexes can slow down data updates.
  • If you are unsure about the correct JSON structure for Index Definition, refer to your database’s documentation or use a sample provided by your development team.
  • Test index changes in a non-production environment first to avoid affecting live data performance.
  • Regularly review and remove unused indexes to keep your database lightweight and fast.

Security Considerations

  • This component relies on the security settings of your configured MongoDB credential. Ensure your credential only has permissions necessary for index management.
  • Never expose sensitive connection strings or passwords directly in shared workflows. Always use the secure credential management feature in Nappai.
  • Index operations do not modify your actual data records, but they do affect how data is stored and retrieved. Always verify collection names before applying changes.
  • For highly sensitive environments, consider restricting index creation permissions to admin-level credentials only.