Metadata_filter for file search stores in interactions API not working

The metadata filter for generateContent via the API seems to work but it doesn’t work on the interactions API. Is this a known issue? I know the syntax is different so will post two examples below but this is extremely frustrating - users are selecting knowledge sources and getting stonewalled by the API.

Example with generate content API which defo works:

{

    "contents": [

{

"role": "user",

"parts": [

{

"text": "User query"

}

]

}

],

"systemInstruction": {

"parts": [

{

"text": "insturction 1"

}

]

},

"tools": [

{

"fileSearch": {

"fileSearchStoreNames": [

"fileSearchStores/store_name"

],

"metadataFilter": "company=\"xxx\" AND (documentUrl=\"xxx\" OR documentUrl=\"xxxx\")"

}

}

]

}

Example with interactions API - filtering is 100% not working.

{

  "model": "gemini-3.1-pro-preview",

"input": "user query",

"tools": [

{

"type": "file_search",

"file_search_store_names": [

"fileSearchStores/store_name"

],

"metadata_filter": "company=\"xxx\" AND (documentUrl=\"xxx\" OR documentUrl=\"xxx\")"

}

],

"stream": false,

"store": true,

"system_instruction": "instruction."

}

Hi there thanks for sharing feedback. Can you share what you mean by “stonewalled by the API” or “100% not working”? Is it working sometimes? Also when it does works is it returning a 200 or the filtering isn’t functionally applied?

I was not able to reproduce this error and ran a simliar command over REST. The command below was able to give me a 200 response with filtering functioning

bash
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key:MY_API_KEY" \
-d '{
   "model": "gemini-3.1-pro-preview",
   "input": "What is the company name in the document?",
   "tools": [
     {
       "type": "file_search",
       "file_search_store_names": ["fileSearchStores/MY_STORE"],
       "metadata_filter": "company=\"xxx\" AND (documenturl=\"xxx\" OR documentUrl=\"xxxx\")"
     }
   ]
}'

Update: I haven’t found the root cause, but it seems like the API only functionally fails when filtering for the key “documentUrl” in my tests. As a short term fix, could you try using different metadata key (e.g doc_url) and filter? Lmk if that works, it worked in my tests.

In the meantime, I’ll look into fixing this bug