# Regex Query

**URL:** <https://discuss.elastic.co/t/regex-query/5296>\
**Category:** Elasticsearch\
**Created:** [September 1, 2011, 1:55pm UTC](https://discuss.elastic.co/t/regex-query/5296 "2011-09-01T13:55:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felix\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_s/32/2933_2.png) [@Felix\_S](https://discuss.elastic.co/u/Felix_S)\
**Post date:** [September 1, 2011, 1:55pm UTC](https://discuss.elastic.co/t/regex-query/5296/1 "2011-09-01T13:55:32Z")

</div>

Hi!

I looked though the guide and googled but couldn't find anything like  
a RegexQueryBuilder. Is there any such thing in ElasticSearch?  
I'd be using it in conjunction with a number of term queries that  
would cut down the number of possible matching documents to a handful,  
and for those I'd like to use a regex instead of the less powerful  
span near queries etc., to select those documents that contain dates  
(any date, not a specific one) etc.

Is there a way to do this?

Regards  
Felix

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [September 1, 2011, 3:39pm UTC](https://discuss.elastic.co/t/regex-query/5296/2 "2011-09-01T15:39:36Z")

</div>

Its not exposed currently in elasticsearch (the lucene one), for reasons of  
performance, the idea (at least back when it was not included) was to wait  
for Lucene 4.0 which includes a faster implementation. Regex is one of those  
things that new users can easily shot themselves in the foot with,  
especially with the current implementation.

On Thu, Sep 1, 2011 at 4:55 PM, Felix Sappelt [f.sappelt@clueda.com](mailto:f.sappelt@clueda.com) wrote:

> Hi!
> 
> I looked though the guide and googled but couldn't find anything like  
> a RegexQueryBuilder. Is there any such thing in Elasticsearch?  
> I'd be using it in conjunction with a number of term queries that  
> would cut down the number of possible matching documents to a handful,  
> and for those I'd like to use a regex instead of the less powerful  
> span near queries etc., to select those documents that contain dates  
> (any date, not a specific one) etc.
> 
> Is there a way to do this?
> 
> Regards  
> Felix

---

<div class="post-metadata">

**Author:** ![Felix\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_s/32/2933_2.png) [@Felix\_S](https://discuss.elastic.co/u/Felix_S)\
**Post date:** [September 12, 2011, 4:20pm UTC](https://discuss.elastic.co/t/regex-query/5296/3 "2011-09-12T16:20:04Z")

</div>

Thanks for your answer! I can see that's the sensible decision, I  
should be able to solve my problem another way.

On 1 Sep., 17:39, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Its not exposed currently in elasticsearch (the lucene one), for reasons of  
> performance, the idea (at least back when it was not included) was to wait  
> for Lucene 4.0 which includes a faster implementation. Regex is one of those  
> things that new users can easily shot themselves in the foot with,  
> especially with the current implementation.
> 
> On Thu, Sep 1, 2011 at 4:55 PM, Felix Sappelt [f.sapp...@clueda.com](mailto:f.sapp...@clueda.com) wrote:
> 
> > Hi!
> 
> > I looked though the guide and googled but couldn't find anything like  
> > a RegexQueryBuilder. Is there any such thing in Elasticsearch?  
> > I'd be using it in conjunction with a number of term queries that  
> > would cut down the number of possible matching documents to a handful,  
> > and for those I'd like to use a regex instead of the less powerful  
> > span near queries etc., to select those documents that contain dates  
> > (any date, not a specific one) etc.
> 
> > Is there a way to do this?
> 
> > Regards  
> > Felix

---

<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 6, 2017, 3:54am UTC](https://discuss.elastic.co/t/regex-query/5296/4 "2017-07-06T03:54:41Z")

</div>


