### 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
assertEquals("field1\u0000jumps", terms.get(5).utf8ToString());
        assertEquals("field1\u0000lazy", terms.get(6).utf8ToString());
        assertEquals("field1\u0000over", terms.get(7).utf8ToString());
        assertEquals("field1\u0000quick", terms.get(8).utf8ToString());
        assertEquals("field1\u0000the", terms.get(9).utf8ToString());
        assertEquals("field2\u0000more", terms.get(10).utf8ToString());
        assertEquals("field2\u0000some", terms.get(11).utf8ToString());
        assertEquals("field2\u0000text", terms.get(12).utf8ToString());
        assertEquals("field4\u0000123", terms.get(13).utf8ToString());
    }
    public void testCreateCandidateQuery() throws Exception {
        int origMaxClauseCount = BooleanQuery.getMaxClauseCount();
        try {
            final int maxClauseCount = 100;
            BooleanQuery.setMaxClauseCount(maxClauseCount);
            addQueryFieldMappings();
            MemoryIndex memoryIndex = new MemoryIndex(false);
            StringBuilder text = new StringBuilder();
            for (int i = 0; i < maxClauseCount - 2; i++) {
                text.append(i).append(' ');
            }
            memoryIndex.addField("field1", text.toString(), new WhitespaceAnalyzer());
            memoryIndex.addField(new LongPoint("field2", 10L), new WhitespaceAnalyzer());
            IndexReader indexReader = memoryIndex.createSearcher().getIndexReader();
            Tuple<BooleanQuery, Boolean> t = fieldType.createCandidateQuery(indexReader);
            assertTrue(t.v2());
            assertEquals(2, t.v1().clauses().size());
            assertThat(t.v1().clauses().get(0).getQuery(), instanceOf(CoveringQuery.class));
            assertThat(t.v1().clauses().get(1).getQuery(), instanceOf(TermQuery.class));