# Perl regex search support in elastic search

**URL:** https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273
**Category:** Elasticsearch
**Created:** [August 17, 2016, 4:26pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273 "2016-08-17T16:26:32Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)
#### Post date: [August 17, 2016, 4:26pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/1 "2016-08-17T16:26:33Z")

</div>

Do we have perl regex support in elastic search?

example:  
perl regex: [a-z]{3}#\s([x,0-9,H,N,L,^,-]){1,}^\d{2}:\d{2}:\d{2}^\d\*((^\d+){1,})((^\d.\d+){1,})  
equivalent java regex: [a-z]{1,3}\# {1,}\^[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\^[0-9]_((\^[0-9]+){1,})((\^[0-9].[0-9]+){1,})._

please suggest if there is any configuration change required.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [August 17, 2016, 4:33pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/2 "2016-08-17T16:33:06Z")

</div>

What are you looking to use regular expressions for? While there is support for running [regexp queries](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-regexp-query.html) in Elasticsearch, these can be very slow and resource intensive.

---

<div class="post-metadata">

### Author: ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)
#### Post date: [August 17, 2016, 5:09pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/3 "2016-08-17T17:09:04Z")

</div>

i have bunch of log files , using logstash to index those into elastic search.  
the java regex is working fine when i do a search, but the perl is not.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 17, 2016, 9:10pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/4 "2016-08-17T21:10:03Z")

</div>

Maybe you could find a better solution by indexing the documents a different way.

---

<div class="post-metadata">

### Author: ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)
#### Post date: [August 17, 2016, 11:41pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/5 "2016-08-17T23:41:29Z")

</div>

> [@warkolm](#):
>
> different way

warkolm, can you please suggest some ways?  
my search should basically cover perl as well as java regex

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 17, 2016, 11:42pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/6 "2016-08-17T23:42:23Z")

</div>

What is the actual problem you are trying to solve?

---

<div class="post-metadata">

### Author: ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)
#### Post date: [August 17, 2016, 11:45pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/7 "2016-08-17T23:45:18Z")

</div>

i indexed the data to elastic search via logstash.

when i construct a regex query with the string, "[a-z]{1,3}# {1,}^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}^0-9((^[0-9].[0-9]+){1,})." i am getting back results. this is the java regular expression.

but when i try to do the similar perl expression, i am not getting results. ex: [a-z]{3}#\s([x,0-9,H,N,L,^,-]){1,}^\d{2}:\d{2}:\d{2}^\d\*((^\d+){1,})((^\d.\d+){1,})

is there a way , elastic search accepts both type of regex strings for search.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 18, 2016, 1:29am UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/8 "2016-08-18T01:29:28Z")

</div>

But why are you even running a regexp query at all? What problem does that solve?

---

<div class="post-metadata">

### Author: ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)
#### Post date: [August 19, 2016, 5:49am UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/9 "2016-08-19T05:49:54Z")

</div>

Hi,

i am not sure if i understand your question. but in the list of documents, the requirement is to support regular expression / full / wildcard searches.  
The regular expression are perfectly working fine, if we construct like this. [a-z]{1,3}# {1,}^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}^0-9((^[0-9].[0-9]+){1,}).

But i realized, users are currently having perl based regular expression. so the equivalent perl regex for the above java regex is below. which is not working  
[a-z]{3}#\s([x,0-9,H,N,L,^,-]){1,}^\d{2}:\d{2}:\d{2}^\d\*((^\d+){1,})((^\d.\d+){1,})

From users perspective, both the regex (Java/perl) are same and they are expecting results for both.

[a-z]{1,3}# {1,}^[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}^0-9((^[0-9].[0-9]+){1,}). (java regex)  
[a-z]{3}#\s([x,0-9,H,N,L,^,-]){1,}^\d{2}:\d{2}:\d{2}^\d\*((^\d+){1,})((^\d.\d+){1,}) (equivalent perl)

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 19, 2016, 6:18am UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/10 "2016-08-19T06:18:21Z")

</div>

> [@subbu.nv](#):
>
> but in the list of documents, the requirement is to support regular expression / full / wildcard searches.

But why does that requirement exist? What search problem is it solving?

---

<div class="post-metadata">

### Author: ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)
#### Post date: [August 19, 2016, 6:48pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/11 "2016-08-19T18:48:27Z")

</div>

> [@warkolm](#):
>
> What search problem is it solving

it is not solving other any problem. but it just using another functionality provided by Elasticsearch.

if the user construct a regex like.. .\*Diag._Version._ it will show the results below.

Diagnostic Version^ v123.0.0\_PST\_MFG123  
Diag Turn-in Blog Version 1.0.3  
etc..

if the regex is having some digits added, it will still bring back results that contains digits between the document.

---

<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: [July 5, 2017, 10:26pm UTC](https://discuss.elastic.co/t/perl-regex-search-support-in-elastic-search/58273/12 "2017-07-05T22:26:33Z")

</div>


