title: Elasticsearch simple query string and highlighter leads to timeout
body: <p>I am facing a strange problem with Elasticsearch:</p>
  <p>I have this query which results in a timeout because it takes more than 60 seconds:</p>
  <pre><code>GET /website/_search
  {
    &quot;query&quot;: {
      &quot;simple_query_string&quot;: {
        &quot;query&quot;: &quot;mbs regex replace all&quot;,
        &quot;fields&quot;: [&quot;content_primary&quot;],
          &quot;default_operator&quot;: &quot;and&quot;
      }
    },
    &quot;highlight&quot;: {
      &quot;fields&quot;: {
        &quot;content_primary&quot;: {}
      }
      ,&quot;fragment_size&quot; : 200
    }
  }
  </code></pre>
  <p>There are 3 options to make the query work:</p>
  <ul>
  <li>Remove the highlight</li>
  <li>Change the default_operator to &quot;OR&quot;</li>
  <li>Remove the word &quot;all&quot; from the query term</li>
  </ul>
  <p>If I remove the highlighter, the query finishes within 9 milliseconds.
  If I search for &quot;mbs regex replace&quot; (without the word &quot;all&quot; and with highlight enabled and operator AND) it finishes within 166 milliseconds.
  If I change the query operator to OR (with highlight enabled) it finishes within 11 milliseconds.</p>
  <p>But for my application, I need all three parameters exactly like specified, because the query &quot;mbs regex replace all&quot; is coming from the user, I need the highlighter for the frontend and I need the operator to be AND, so the search works like the user expect it.</p>
  <p>What is wrong here?</p>
  <p>The index has 96743 documents.
  Elasticsearch v7.11.2 hosted on cloud.elastic.co</p>
  <p>Edit: this is the mapping:</p>
  <pre><code>
  PUT /website
  {
    &quot;settings&quot;: {
      &quot;analysis&quot;: {
        &quot;filter&quot; : {
          &quot;custom_synonym&quot; :  {
            &quot;type&quot; : &quot;synonym&quot;,
            &quot;lenient&quot;: true,
            &quot;synonyms&quot;: [ &quot;FM =&gt; FileMaker&quot;, &quot;DDR =&gt; Datenbank Design Report&quot;, &quot;DB =&gt; Datenbank&quot;, &quot;TO, Table Occurence =&gt; Tabellenauftreten&quot; ]
          },
          &quot;german_stemming&quot;: {
            &quot;type&quot;: &quot;stemmer&quot;,
            &quot;language&quot;: &quot;german&quot;
          },
          &quot;german_stopping&quot;: {
            &quot;type&quot;: &quot;stop&quot;,
            &quot;stopwords&quot;: &quot;_german_&quot;
          }
        },
        &quot;analyzer&quot;: {
          &quot;custom_german_analyzer&quot;: {
            &quot;type&quot;: &quot;custom&quot;,
            &quot;tokenizer&quot;: &quot;standard&quot;,
            &quot;filter&quot;: [&quot;lowercase&quot;, &quot;asciifolding&quot;, &quot;custom_synonym&quot;]
          }
        }
      }
    },  
      &quot;mappings&quot; : {
        &quot;properties&quot; : {
          &quot;authors&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;classifications&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;content_primary&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              },
              &quot;german&quot; : {
                &quot;type&quot;: &quot;text&quot;,
                &quot;analyzer&quot;: &quot;custom_german_analyzer&quot;
              }
            }
          },
          &quot;date&quot; : {
            &quot;type&quot; : &quot;date&quot;
          },
          &quot;description&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;domain&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;id&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;keywords&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;language&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;properties&quot; : {
            &quot;properties&quot; : {
              &quot;Plugin Komponente&quot; : {
                &quot;type&quot; : &quot;text&quot;,
                &quot;fields&quot; : {
                  &quot;keyword&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;,
                    &quot;ignore_above&quot; : 256
                  }
                }
              },
              &quot;osversion&quot; : {
                &quot;type&quot; : &quot;text&quot;,
                &quot;fields&quot; : {
                  &quot;keyword&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;,
                    &quot;ignore_above&quot; : 256
                  }
                }
              },
              &quot;softwareversion&quot; : {
                &quot;type&quot; : &quot;text&quot;,
                &quot;fields&quot; : {
                  &quot;keyword&quot; : {
                    &quot;type&quot; : &quot;keyword&quot;,
                    &quot;ignore_above&quot; : 256
                  }
                }
              }
            }
          },
          &quot;source&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;title&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              },
              &quot;german&quot; : {
                &quot;type&quot;: &quot;text&quot;,
                &quot;analyzer&quot;: &quot;custom_german_analyzer&quot;
              }
            }
          },
          &quot;url&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          },
          &quot;urlToImagePreview&quot; : {
            &quot;type&quot; : &quot;text&quot;,
            &quot;fields&quot; : {
              &quot;keyword&quot; : {
                &quot;type&quot; : &quot;keyword&quot;,
                &quot;ignore_above&quot; : 256
              }
            }
          }
        }
      }
  }
  </code></pre>
  <p>Thank you!</p>