Connecting to a Milvus content repository

Connect a Milvus content repository to support high-performance vector search. During runtime, the agent queries the Milvus instance to retrieve relevant content for accurate, context-based results.

Use Milvus to improve retrieval accuracy for long or detailed content. Vector search provides more relevant results than basic keyword matching.

Use the following products or tools to connect to a content repository on Milvus:

  • IBM® watsonx.data (SaaS version), where you provision the Milvus instance.
  • watsonx.ai (optional), used only if you want to create collections and load data.
  • agent builder, where you build agents and set up the connection with a Milvus instance.

Comply with the prerequisites for connecting Milvus before you start the procedure to connect your agent to a content repository on a Milvus instance.

Before you connect to Milvus

Before connecting your agent to Milvus:

Connect your agent to Milvus

Use data on your Milvus instance in IBM® watsonx.data to connect your agent to it:

Note: The Choose knowledge + option does not appear if a different knowledge source is already connected. To switch sources, click Replace source, select your new source, confirm by clicking I understand. When you replace the source, all previous repository details and files are deleted and cannot be recovered.

  1. On the agent configuration page, go to the Knowledge section.

  2. Click Choose knowledge +.

  3. Under Add source, click New knowledge.

  4. Select Milvus and click Next.

  5. On the Connect Milvus page, provide the connection details.

  6. In the GRPC host, enter the endpoint URL of the Milvus host.

  7. In GRPC port (required), enter the port to connect to the Milvus host.

    To get the details of GRPC host and GRPC port, see Connection details.

  8. In Choose an authentication type, select Basic authentication or API key.

    • If you select Basic authentication, you must provide a username and password.
    • If you select watsonx.data API key, you must provide the corresponding API key.
    • If you select None, you don't need to provide any other authentication details.

    For more information about credentials, see Getting credentials.

  9. Click Next to proceed.

    After you collect information from IBM® watsonx.data, you must ingest data into the Milvus database to use in your agent.

    In Select index, provide the following details:

  10. In Database, select the name of the database.

  11. Select Alias or Collection. For more information, see Before you connect to Milvus. For more information on Alias, see Using an alias for collection management.

  12. Select the Collection name or type the Alias.

  13. In Index, select the index.

  14. In Embedding model, select a model from the drop-down list.

    For more information on the supported embedding models, see Embedding models.{: external}.

    Note:
    - The embedding model that you enter must match the one used to create the index.
    - You can use a model from watsonx.ai or a third-party provider.

    After you connect Milvus by selecting the data source, you can configure how the search response displays in the Milvus window of your assistant. In the Configure result content, provide the following fields to map the title, body, and URL from Milvus to the search response:

    1. Title: Select the search result title.
    2. Body: Select the search result description.
    3. URL (optional): Select the URL to include at the end of the search result.
  15. Click Next to proceed.

  16. In the Knowledge details section,

  17. Save your settings.

Update Milvus settings

To change the settings of the Milvus content repository:

  1. Go to the Knowledge section.
  2. Click the vertical ellipsis () next to the selected knowledge source.
  3. Select Edit details and update the configuration.
  4. Save your settings.

Delete Milvus repository

To delete a Milvus content repository:

  1. Go to the Knowledge section.
  2. Click the vertical ellipsis () next to the selected knowledge source.
  3. Click Remove.

Update Milvus authentication credentials

IBM watsonx.data version 2.3 removes the default Milvus username ibmlhapikey. If you use Milvus with watsonx Orchestrate agent knowledge or watsonx Assistant search integration, update your connection by 10 December 2025 to avoid critical service interruptions.

The following are the steps to update your credentials:

Step 1: Find your new Milvus username

Your new Milvus username uses the following format:

ibmlhapikey_<your watsonx.data username>

Examples

watsonx.data username Milvus username
abc@ibm.com ibmlhapikey_abc@ibm.com
serviceid-abcdef-123456 ibmlhapikey_serviceid-abcdef-123456

If you do not know your watsonx.data username:

  1. Go to Infrastructure manager in IBM watsonx.data console.
  2. Select your Milvus service to open the Details page.
  3. Click the Access control tab.
    Your watsonx.data usernames appear in the first column of the table.

Step 2: Update your Milvus connection

Follow the steps to update your Milvus credentials for each agent that uses a Milvus knowledge source:

  1. On the agent configuration page, go to the Knowledge section.
  2. Click Settings next to the Milvus entry under Knowledge source.
  3. Record your existing connection information. You need to have a complete record of all your current Milvus settings so that you can enter them again after you update your Milvus credentials.
  4. Go to the Instance tab and click Update details.
  5. Specify your connection details:
    • GRPC host and GRPC port.
    • Username: Use your new Milvus username from Step 1: Find your new Milvus username.
    • Password: Use the same password or API key that you used earlier.
      If you are authenticated with a watsonx.data API key, that same key now acts as your password.
  6. Click Next, and reenter your collection, alias, and index information.
  7. Test the agent’s knowledge by using the chat window to confirm Milvus search results appear correctly.

Define filter expressions

In the Advanced Milvus settings section, you can configure the custom filter to query results from Milvus. This following example shows how you can define a filter expression:

  • Contains: Returns only the search results with title that contains the word action. Example:

    title like "%action%"
    
  • Doesn't contain: Returns only the search results with title not containing the word action. Example:

    not (title like "%action%")
    
  • Nested filter expression: Returns only the search results with the title that contains the word "action" and the url being one of ["www.url1.com", "www.url2.com"]. Example:

    (title like "%action%") and (url in ["www.url1.com", "www.url2.com"])
    

Pass context variables

You can make your filters dynamic by referencing context variables in your Milvus filter templates. This enables runtime substitution of values based on user or session context, making your queries more flexible and personalized.

How it works

  • In your content repository, set up filters and reference context variables in the format: {context_var}
  • When the agent runs, it fetches context from:
    • The runs endpoint payload, or
    • The JWT token associated with the session
  • The knowledge runtime replaces the context variables in your filter template with actual values from the context

Example for Milvus filter substitution

The example includes:

  • filter: A template with references to context variables, entered in the filter field for dynamic substitution.

  • final_filter: The template after replacing context variables with actual values. The query is sent to Milvus for data retrieval.

  • context_variable: A set of key-value pairs defining the context variables used in substitution.

Example:

    filter = "(title like \"%{action}%\") and (url in {url})"
    context_variable = {"action": "send-email", "url": ["a.com", "b.com"]}
    final_filter = "(title like \"%send-email%\") and (url in [\"a.com\", \"b.com\"])"

Manage collections with aliases

Use an alias to separate your application logic from a specific collection name. This approach helps you update collections without downtime or changes to your client configuration.

For example, if your application queries a collection called prod_data, you can update the underlying data without interrupting the service. Do the following steps:

  1. Create a new collection: Create a new collection such as prod_data_v2.

  2. Prepare the data: Load and index your data in prod_data_v2.

  3. Switch the alias: When the collection is ready, reassign the alias prod_data from the old collection to the new one.

Your application continues to query prod_data without needing to know the physical collection name. This method supports seamless updates and simplifies tasks such as blue-green deployments. For more information, see Why Use an Alias?

What to do next

After you connect to Milvus, you can modify the repository connection data or the settings you provided to fetch the documents.

Also, if you want to fine-tune how your agent uses the search results, see Editing the settings of the search results.