# Best way to identify input error for multi\_match?

**URL:** https://discuss.elastic.co/t/best-way-to-identify-input-error-for-multi-match/381889
**Category:** Elasticsearch
**Created:** [September 11, 2025, 9:11pm UTC](https://discuss.elastic.co/t/best-way-to-identify-input-error-for-multi-match/381889 "2025-09-11T21:11:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nonword](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nonword/32/145001_2.png) [@nonword](https://discuss.elastic.co/u/nonword)
#### Post date: [September 11, 2025, 9:11pm UTC](https://discuss.elastic.co/t/best-way-to-identify-input-error-for-multi-match/381889/1 "2025-09-11T21:11:44Z")

</div>

We’re passing user input into a multi\_match with minimal escaping. If the user searches `”something` (unbalanced quotes), ES responds with a 400:

```auto
{
  root_cause: [
    {
      type: 'token_mgr_error',
      reason: 'token_mgr_error: Lexical error at line 1, column 10. Encountered: <EOF> after prefix "\\"something" (in lexical state 2)'
    }
  ],
  type: 'search_phase_execution_exception',
  reason: 'all shards failed',
  phase: 'query',
  grouped: true,
  failed_shards: [...],
  caused_by: {
    type: 'token_mgr_error',
    reason: 'token_mgr_error: Lexical error at line 1, column 10. Encountered: <EOF> after prefix "\\"something" (in lexical state 2)'
  }

```

I can’t find documentation on exceptions. Can I reliably assume `search_phase_execution_exception` indicates user input error or should I check for `token_mgr_error` - or something else? I’d like to distinguish user-input issues from deeper issues.

Thanks!

---

<div class="post-metadata">

### Author: ![Rafa\_Silva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafa_silva/32/147814_2.png) [@Rafa\_Silva](https://discuss.elastic.co/u/Rafa_Silva)
#### Post date: [September 13, 2025, 12:57am UTC](https://discuss.elastic.co/t/best-way-to-identify-input-error-for-multi-match/381889/2 "2025-09-13T00:57:51Z")

</div>

You should check for token\_mgr\_error in the caused\_by section that’s the specific signal of invalid user input. search\_phase\_execution\_exception is more general and can also come from deeper issues.
