# Regexp not working in head plugin

**URL:** <https://discuss.elastic.co/t/regexp-not-working-in-head-plugin/16955>\
**Category:** Elasticsearch\
**Created:** [April 11, 2014, 12:55pm UTC](https://discuss.elastic.co/t/regexp-not-working-in-head-plugin/16955 "2014-04-11T12:55:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronny\_Deter](https://avatars.discourse-cdn.com/v4/letter/r/d2c977/32.png) [@Ronny\_Deter](https://discuss.elastic.co/u/Ronny_Deter)\
**Post date:** [April 11, 2014, 12:55pm UTC](https://discuss.elastic.co/t/regexp-not-working-in-head-plugin/16955/1 "2014-04-11T12:55:30Z")

</div>

The regexp query or filter not working in my case.  
Here my data

{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 1 }}

{ "name" : "New York", "combined" : "2014-BBBFFFBBBFFF" }

{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 2 }}

{ "name" : "London", "combined" : "2015-FFFFFBBBBFFFF" }

{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 3 }}

{ "name" : "Moscow", "combined" : "2014-FFFFFBBBBBBBBBB"}

{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 4 }}

{ "name" : "Sydney", "combined" : "2015-BBBBBBBBBBBBBBBB" }

My search query

{

"query": {

```
"regexp": {

  "item.combined": "2014-b{3}f{3}*"

}

```

},

"from": 0,

"size": 25

}  
to find the first entry, but is not working.

What i wnat to do is search in combined for a year and substr at position x  
to position y with a f. Any character before or after positions can be any  
character.  
When i create a regex on [http://regex101.com/](http://regex101.com/) to find f in the string it  
has this regex 2014-.{3}F{3}.\* to match 2014-BBBFFFBBBFFF

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 21, 2014, 12:04pm UTC](https://discuss.elastic.co/t/regexp-not-working-in-head-plugin/16955/2 "2014-04-21T12:04:31Z")

</div>

Hey,

keep in mind, that the regexp query is a term query with regex support, so  
having analyzed fields is a problem, try the following example:

DELETE /map  
PUT /map

PUT /map/item/\_mapping  
{  
"properties": {  
"combined" : { "type": "string", "index": "not\_analyzed"}  
}  
}

GET /map/item/\_mapping

PUT /\_bulk  
{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 1 }}  
{ "name" : "New York", "combined" : "2014-BBBFFFBBBFFF" }  
{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 2 }}  
{ "name" : "London", "combined" : "2015-FFFFFBBBBFFFF" }  
{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 3 }}  
{ "name" : "Moscow", "combined" : "2014-FFFFFBBBBBBBBBB"}  
{ "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 4 }}  
{ "name" : "Sydney", "combined" : "2015-BBBBBBBBBBBBBBBB" }

GET /map/\_search  
{  
"query": {  
"regexp": {  
"item.combined": "2014-B{3}F{3}.\*"  
}  
},  
"from": 0,  
"size": 25  
}

As you can see, I changed the mapping and the regex slightly.. not sure if  
it helps you.

--Alex

On Fri, Apr 11, 2014 at 2:55 PM, [ronny.deter@campanda.com](mailto:ronny.deter@campanda.com) wrote:

> The regexp query or filter not working in my case.  
> Here my data
> 
> { "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 1 }}
> 
> { "name" : "New York", "combined" : "2014-BBBFFFBBBFFF" }
> 
> { "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 2 }}
> 
> { "name" : "London", "combined" : "2015-FFFFFBBBBFFFF" }
> 
> { "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 3 }}
> 
> { "name" : "Moscow", "combined" : "2014-FFFFFBBBBBBBBBB"}
> 
> { "index" : { "\_index" : "map", "\_type" : "item", "\_id" : 4 }}
> 
> { "name" : "Sydney", "combined" : "2015-BBBBBBBBBBBBBBBB" }
> 
> My search query
> 
> {
> 
> "query": {
> 
> ```
> "regexp": {
> 
> "item.combined": "2014-b{3}f{3}*"
> 
> }
> 
> ```
> 
> },
> 
> "from": 0,
> 
> "size": 25
> 
> }  
> to find the first entry, but is not working.
> 
> What i wnat to do is search in combined for a year and substr at position  
> x to position y with a f. Any character before or after positions can be  
> any character.  
> When i create a regex on [http://regex101.com/](http://regex101.com/) to find f in the string it  
> has this regex 2014-.{3}F{3}.\* to match 2014-BBBFFFBBBFFF
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b7f2a8cb-8887-4d90-bbd6-9c32e1250c6b%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-UtDtS7aKsn%3D9ba-70GSNq8TYUcve-5ZUSuzpSTwsKNA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-UtDtS7aKsn%3D9ba-70GSNq8TYUcve-5ZUSuzpSTwsKNA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:34am UTC](https://discuss.elastic.co/t/regexp-not-working-in-head-plugin/16955/3 "2017-07-06T01:34:38Z")

</div>


