### Elasticsearch Version

8.6 and above

### Installed Plugins

_No response_

### Java Version

_bundled_

### OS Version

Unix

### Problem Description

While trying to run a script query on an index with a percolator type field but running into error 
```
        "type": "document_parsing_exception",
        "reason": "[10:39] failed to parse: [10:39] [bool] failed to parse field [filter]"
```
This worked in 7.17.0 but does not work in 8.6 (also on current main )

### Steps to Reproduce


1. Create index with percolator field
```
PUT /debug-index-01
{
    "mappings": {
        "properties": {
            "query": {
                "type": "percolator"
            }
        }
    }
}
```
2. Run POST with script on index
```
POST /debug-index-01/_doc
{
    "query": {
        "bool": {
            "filter": [
                {
                    "script": {
                        "script": {
                            "source": "return params.x ? true : false",
                            "lang": "painless",
                            "params": {
                                "x": true
                            }
                        }
                    }
                }
            ]
        }
    }
}
```

On 7.17 it says creates the document.
On 8.8.2 it gives the response below:
```
{
  "error": {
    "root_cause": [
      {
        "type": "document_parsing_exception",
        "reason": "[10:39] failed to parse: [10:39] [bool] failed to parse field [filter]"
      }
    ],
    "type": "document_parsing_exception",
    "reason": "[10:39] failed to parse: [10:39] [bool] failed to parse field [filter]",
    "caused_by": {
      "type": "x_content_parse_exception",
      "reason": "[10:39] [bool] failed to parse field [filter]",
      "caused_by": {
        "type": "x_content_parse_exception",
        "reason": "[10:39] [script] failed to parse field [params]",
        "caused_by": {
          "type": "unsupported_operation_exception",
          "reason": null
        }
      }
    }
  },
  "status": 400
}
```

### Logs (if relevant)

_No response_
server/src/test/java/org/elasticsearch/index/mapper/DotExpandingXContentParserTests.java
final ContentPath contentPath = new ContentPath();
        XContentParser expandedParser = DotExpandingXContentParser.expandDots(inputParser, contentPath);
        expandedParser.allowDuplicateKeys(true);
        XContentBuilder actualOutput = XContentBuilder.builder(JsonXContent.jsonXContent).copyCurrentStructure(expandedParser);
        assertEquals(dotsExpanded, Strings.toString(actualOutput));
        XContentParser expectedParser = createParser(JsonXContent.jsonXContent, dotsExpanded);
        expectedParser.allowDuplicateKeys(true);
        XContentParser actualParser = DotExpandingXContentParser.expandDots(createParser(JsonXContent.jsonXContent, withDots), contentPath);
        XContentParser.Token currentToken;
        while ((currentToken = actualParser.nextToken()) != null) {
            assertEquals(currentToken, expectedParser.nextToken());
            assertEquals(expectedParser.currentToken(), actualParser.currentToken());
            assertEquals(actualParser.currentToken().name(), expectedParser.currentName(), actualParser.currentName());
        }
        assertNull(expectedParser.nextToken());
    }
    public void testEmbeddedObject() throws IOException {
        assertXContentMatches("""
            {"test":{"with":{"dots":{"field":"value"}}},"nodots":"value2"}\
            """, """
            {"test.with.dots":{"field":"value"},"nodots":"value2"}\
            """);
    }
    public void testEmbeddedObjects() throws IOException {
        assertXContentMatches("""
            {"test":{"with":{"dots":{"obj":{"field":"value","array":["value",{"field":"value"}]}}}},"nodots":"value2"}\
            """, """
            {"test.with.dots":{"obj":{"field":"value","array":["value",{"field":"value"}]}},"nodots":"value2"}\
            """);
    }