[script] Too many dynamic script compilations within one minute, max: [15/min]

I have almost 10K of scripts like this:

POST _scripts/536672d3cface3ddbb63666bf1b6030f
{
  "script": {
      "lang": "painless",
      "source": "Pattern p = /\\s?a\\S*?/i; p.matcher(params._source.summary ?: '').find();"
   }
}

Query:

{
   "query": {
      "bool": {
         "must": [
            {
               "bool": {
                  "must": [
                     {
                        "query_string": {
                           "query": "a*",
                           "quote_analyzer": "standard",
                           "allow_leading_wildcard": "true",
                           "analyze_wildcard": "true",
                           "default_operator": "AND",
                           "phrase_slop": 1
                        }
                     },
                     {
                        "script": {
                           "script": {
                              "id": "536672d3cface3ddbb63666bf1b6030f"
                           }
                        }
                     }
                  ]
               }
            }
         ]
      }
   }
}

everything stored in a percolator, when it is getting percolated I am getting [script] Too many dynamic script compilations within one minute, max: [15/min].

I have changed from 15 to 5000, of course our executions are more than 500 / minutes and failing.

In anyway we can handle this error

Or or requirement is support wildcards like our users will search for aus* gov* , aus* poli* blah* or any combination of wildcard with multiple words.

other than scripting any other way to support wildcard search?

Tried with ngrams and edge-ngrams, but it is not the perfect match and ended in script, but it is failing here.

Script with parameter won't work with Pattern otherwise I could have used parameterized scripts!

A script should not be needed here. While it will be just as inefficient from a query perspective, have you tried the regex query?

didn't work with aus* gov* , aus* poli* blah* or any combination of wildcard with multiple words.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

didn't work with aus* gov*

A couple things to note:

  • If these are meant to be multiple terms, they need to be in multiple clauses. Ie if you are trying to match documents with the terms beginning with aus and terms beginning with gov you need need a bool query with a must clause for each. In this case, a prefix_query would be best.
  • Putting aus* into a regex query won't work. That is the query string syntax for a prefix query. Please read the full documentation for the regex query I liked previously. In this case, the pattern would look something like aus.* (but again, this particular query would be better as a prefix_query).

problem is not aus* it is aus* gov*. It is a phrase. I wanted to match a phrase if we use boolean it will batch the words not as a phrase. isn't it?

If you want to do phrase matching with wildcards, you should probably look at span queries. But do so with caution: phrase and wildcards are much slower than normal queries, and combining them will perform even worse.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.