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:
-
Have an active account on the SaaS version of IBM® watsonx.data. To create an account, see IBM® watsonx.data home page.
-
(Optional) If using watsonx.ai for collections or data loading, ensure you have an active account on watsonx.ai. To create an account, see watsonx.ai home page .
-
Provision a Milvus instance in IBM® watsonx.data. For more information, see Adding Milvus service in IBM® watsonx.data. For more information on creating an API key, see API keys.
-
Configure IBM® watsonx.data Milvus in IBM watsonx.ai and create a vector index. For more information about creating collections, see Creating collections.
Connect your agent to Milvus
Use data on your Milvus instance in IBM® watsonx.data to connect your agent to it:
-
On the agent configuration page, go to the Knowledge section.
-
Click Choose knowledge +.
-
Under Add source, click New knowledge.
-
Select Milvus and click Next.
-
On the Connect Milvus page, provide the connection details.
-
In the GRPC host, enter the endpoint URL of the Milvus host.
-
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.
-
In Choose an authentication type, select
Basic authenticationorAPI 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.
- If you select
-
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:
-
In Database, select the name of the database.
-
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.
-
Select the Collection name or type the Alias.
-
In Index, select the index.
-
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:
- Title: Select the search result title.
- Body: Select the search result description.
- URL (optional): Select the URL to include at the end of the search result.
-
Click Next to proceed.
-
In the Knowledge details section,
Name: Enter a display name for the knowledge source.Description: Provide a short description. For more information, see Providing context about the knowledge to the agent.
-
Save your settings.
Update Milvus settings
To change the settings of the Milvus content repository:
- Go to the Knowledge section.
- Click the vertical ellipsis (⋮) next to the selected knowledge source.
- Select Edit details and update the configuration.
- Save your settings.
Delete Milvus repository
To delete a Milvus content repository:
- Go to the Knowledge section.
- Click the vertical ellipsis (⋮) next to the selected knowledge source.
- 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:
- Go to Infrastructure manager in IBM watsonx.data console.
- Select your Milvus service to open the Details page.
- 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:
- On the agent configuration page, go to the Knowledge section.
- Click Settings next to the Milvus entry under Knowledge source.
- 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.
- Go to the Instance tab and click Update details.
- 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.
- Click Next, and reenter your collection, alias, and index information.
- If the connection works, your new credentials are valid.
- If you see an error, review Step 1: Find your new Milvus username to confirm your username and password.
- 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:
-
Create a new collection: Create a new collection such as prod_data_v2.
-
Prepare the data: Load and index your data in prod_data_v2.
-
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.