Add filters to a Microsoft OneDrive data store

This page explains how to add filters to your Microsoft OneDrive data stores in Gemini Enterprise. Filters determine which information is retrieved or excluded from the Microsoft OneDrive data store when users chat with the Assistant using the Gemini Enterprise app.

Filter types

You can configure the following filters within the params object of your data connector:

  • Inclusion filter (admin_filter): Retrieves only specific information from the Microsoft OneDrive data store.
  • Exclusion filter (admin_exclusion_filter): Excludes specific information from the Microsoft OneDrive data store.
  • Legacy filter (structured_search_filter): Previously used to create a data store with filters using the API.

Filter keys

The filter parameters accept an object containing key-value pairs. The keys represent the Microsoft OneDrive fields you want to filter on, and the values are arrays of strings containing the criteria to match. When updating filters using the API, the following keys are supported:

Filter name FILTER_KEY Description Supported URL examples
Path Path Filters search results based on specific URL prefixes. Use this for granular control to include or exclude specific sub-folders or files. https://tenant1-my.sharepoint.com/personal/alice_company_com/*
https://tenant1-my.sharepoint.com/personal/*
https://tenant1.sharepoint.com/sites/onboarding/Documents2/
https://tenant1-my.sharepoint.com/personal/user_tenant1_com/Documents/folder1

Update filters in an existing data store

You can update filters in an existing data store using either the Google Cloud console or the API.

Console

To modify existing filter configurations:
  1. In the Google Cloud console navigation menu, click Data stores.
  2. Select your Microsoft OneDrive data store.
  3. Click View/edit parameters.
  4. In the View/edit parameters panel, add or update the Microsoft OneDrive URLs and filter types.
  5. Click Save.

REST

To add or to update filters in an existing Microsoft OneDrive data store, call the updateDataConnector method with any one of these fields:

  • The admin_filter field for inclusion filter.
  • The admin_exclusion_filter field for exclusion filter.
  • The legacy structured_search_filter field.

In the request body, the field must contain all the filters you want to have in the data store, including the filters that are not updated.

To add or update filters in an existing OneDrive data store, run the following command:

        curl -X PATCH 
-H "Authorization: Bearer $(gcloud auth print-access-token)"
-H "Content-Type: application/json"
-H "X-Goog-User-Project: PROJECT_ID"
"https://ENDPOINT_LOCATION-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/COLLECTION_ID/dataConnector?updateMask=params"
-d '{ "params": { "FILTER_TYPE": { "FILTER_KEY": [ "UPDATED_FILTER_VALUE1", "UPDATED_FILTER_VALUE2" ] } } }'

Replace the following:

  • PROJECT_ID: the ID of your project.
  • ENDPOINT_LOCATION: the multi-region for your API request. Specify one of the following values:
    • us for the US multi-region
    • eu for the EU multi-region
    • global for the Global location
    For more information, see Specify a multi-region for your data store.
  • LOCATION: the multi-region of your data store: global, us, or eu
  • COLLECTION_ID: The ID of the collection containing the data store.
  • FILTER_TYPE: the type of filter added to your Microsoft OneDrive data stores. For more information, see Filter types.
  • FILTER_KEY: the key for the filter, corresponding to a field in your data. For more information, see Filter keys.
  • UPDATED_FILTER_VALUE1: the value to filter on for the specified FILTER_KEY.
  • UPDATED_FILTER_VALUE2: the value to filter on for the specified FILTER_KEY.

Important Considerations

  • If you switch from an inclusion filter to an exclusion filter, or from an exclusion filter to an inclusion filter, you must explicitly remove the filter that is no longer required by setting it to empty in the request body. For example, if you have an admin_filter and want to switch to admin_exclusion_filter, include "admin_filter": {} in addition to admin_exclusion_filter in your API request params object. The following example shows params object when switching from admin_filter to admin_exclusion_filter:

            "params": {
              "admin_filter": {},
              "admin_exclusion_filter": {
                "Path": ["https://tenant1.sharepoint.com/sites/hr-portal-site"]
              }
            }
            
  • When updating filters, you must include the previously added filters as well.

Exclude SharePoint content from OneDrive

By default, the Microsoft API returns both SharePoint and OneDrive content. To exclude SharePoint files from the search results, apply one of the following Path filters:

Use an inclusion filter

If you are using inclusion filters, add the following URL to the inclusion filter list to restrict indexing to OneDrive-only data:

https://{your-tenant}-my.sharepoint.com/personal/*

Use an exclusion filter

If you are using exclusion filters, append the following URL to the exclusion filter list to exclude all SharePoint files from the search results:

https://{your-tenant}.sharepoint.com/sites/*

Verify that the data store includes the filters

You can get the details of the data store to confirm that the filters you added or updated are correctly applied using the Google Cloud console or the API:

Console

To view the existing filter configurations:
  1. In the Google Cloud console > navigation menu, click Data stores.
  2. Select your Microsoft OneDrive data store.
  3. Click View/edit parameters.

In the View/edit parameters panel, the existing filters applied to the data store are displayed.

REST

To verify data store settings, call the getDataConnector method:

        curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        -H "X-Goog-User-Project: PROJECT_ID" \
        "https://ENDPOINT_LOCATION-discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/collections/COLLECTION_ID/dataConnector"
        

Replace the following:

  • PROJECT_ID: the ID of your project.
  • ENDPOINT_LOCATION: the multi-region for your API request. Specify one of the following values:
    • us for the US multi-region
    • eu for the EU multi-region
    • global for the Global location
    For more information, see Specify a multi-region for your data store.
  • LOCATION: the multi-region of your data store: global, us, or eu
  • COLLECTION_ID: the ID of the collection containing the data store.

In the response, view the admin_filter, admin_exclusion_filter, or structured_search_filter fields in params to verify the filters.

What's next