### 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_
modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java
} else {
            query.startObject("script");
            query.field("source", "return true");
            query.endObject();
        }
        query.endObject();
        query.endObject();
        query.endArray();
        query.endObject();
        query.endObject();
        doc = mapperService.documentMapper()
            .parse(
                new SourceToParse(
                    "1",
                    BytesReference.bytes(
                        XContentFactory.jsonBuilder()
                            .startObject()
                            .rawField(fieldName, new BytesArray(Strings.toString(query)).streamInput(), query.contentType())
                            .endObject()
                    ),
                    XContentType.JSON
                )
            );
        querySource = doc.rootDoc().getFields(fieldType.queryBuilderField.name()).get(0).binaryValue();
        try (InputStream in = new ByteArrayInputStream(querySource.bytes, querySource.offset, querySource.length)) {
            try (StreamInput input = new NamedWriteableAwareStreamInput(new InputStreamStreamInput(in), writableRegistry())) {
                input.readVInt();
                input.readVInt();
                TransportVersion.readVersion(input);
                FunctionScoreQueryBuilder queryBuilder = (FunctionScoreQueryBuilder) input.readNamedWriteable(QueryBuilder.class);