# ES regex match failure

**URL:** <https://discuss.elastic.co/t/es-regex-match-failure/250282>\
**Category:** Elasticsearch\
**Created:** [September 29, 2020, 3:31am UTC](https://discuss.elastic.co/t/es-regex-match-failure/250282 "2020-09-29T03:31:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![f4ct0r](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/f4ct0r/32/24229_2.png) [@f4ct0r](https://discuss.elastic.co/u/f4ct0r)\
**Post date:** [September 29, 2020, 3:31am UTC](https://discuss.elastic.co/t/es-regex-match-failure/250282/1 "2020-09-29T03:31:57Z")

</div>

Hey guys,  
I wanna match some data about form-data in ES like

```auto
------WebKitFormBoundary9fB75AOSG0bMs1I4\x0D\x0AContent-Disposition: form-data; name=\x22upload\x22; filename=\x22shell.php\x22\x0D\x0AContent-Type: application/octet-stream\x0D\x0A\x0D\x0A<?php\x0D\x0Aerror_reporting(7);\x0D\x0A@set_magic_quotes_runtime(0);

```

And the data type is keyword, so I'm using regexp like this

```auto
{
  "query": {
      "regexp": {
         "data": ".*\\<\\?php.*"
      }
   }
}

```

But nothing return  
The ES version is 7.8.1, Is there something wrong about this pattern?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 29, 2020, 9:13am UTC](https://discuss.elastic.co/t/es-regex-match-failure/250282/2 "2020-09-29T09:13:36Z")

</div>

Nothing wrong with the pattern - likely the content wasn't indexed because it is a long string.  
By default `keyword` fields drop strings greater than 256 chars in length. This `ignore_above` setting can be increased but there's a hard limit of 32k.

A potentially better way of searching long strings is the new `wildcard` field in 7.9.  
Check out the [blog](https://www.elastic.co/blog/find-strings-within-strings-faster-with-the-new-elasticsearch-wildcard-field)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 27, 2020, 9:13am UTC](https://discuss.elastic.co/t/es-regex-match-failure/250282/3 "2020-10-27T09:13:37Z")

</div>

Closed on October 27, 2020, 9:13am UTC

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