### 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
memoryIndex.addField("field2", "value", new WhitespaceAnalyzer());
            indexReader = memoryIndex.createSearcher().getIndexReader();
            t = fieldType.createCandidateQuery(indexReader);
            assertFalse(t.v2());
            assertEquals(3, t.v1().clauses().size());
            TermInSetQuery terms = (TermInSetQuery) t.v1().clauses().get(0).getQuery();
            assertEquals(maxClauseCount - 1, terms.getTermData().size());
            assertThat(t.v1().clauses().get(1).getQuery().toString(), containsString(fieldName + ".range_field:<ranges:"));
            assertThat(t.v1().clauses().get(2).getQuery().toString(), containsString(fieldName + ".extraction_result:failed"));
        } finally {
            BooleanQuery.setMaxClauseCount(origMaxClauseCount);
        }
    }
    public void testExtractTermsAndRanges_numberFields() throws Exception {
        addQueryFieldMappings();
        MemoryIndex memoryIndex = new MemoryIndex(false);
        memoryIndex.addField(new IntPoint("number_field1", 10), new WhitespaceAnalyzer());
        memoryIndex.addField(new LongPoint("number_field2", 20L), new WhitespaceAnalyzer());
        memoryIndex.addField(new LongPoint("number_field3", 30L), new WhitespaceAnalyzer());
        memoryIndex.addField(new HalfFloatPoint("number_field4", 30f), new WhitespaceAnalyzer());
        memoryIndex.addField(new FloatPoint("number_field5", 40f), new WhitespaceAnalyzer());
        memoryIndex.addField(new DoublePoint("number_field6", 50f), new WhitespaceAnalyzer());
        memoryIndex.addField(new InetAddressPoint("number_field7", InetAddresses.forString("192.168.1.12")), new WhitespaceAnalyzer());
        memoryIndex.addField(new InetAddressPoint("number_field7", InetAddresses.forString("192.168.1.20")), new WhitespaceAnalyzer());
        memoryIndex.addField(new InetAddressPoint("number_field7", InetAddresses.forString("192.168.1.24")), new WhitespaceAnalyzer());
        IndexReader indexReader = memoryIndex.createSearcher().getIndexReader();
        Tuple<List<BytesRef>, Map<String, List<byte[]>>> t = PercolatorFieldMapper.PercolatorFieldType.extractTermsAndRanges(indexReader);
        assertEquals(0, t.v1().size());
        Map<String, List<byte[]>> rangesMap = t.v2();
        assertEquals(7, rangesMap.size());