# Using regular expression

**URL:** https://discuss.elastic.co/t/using-regular-expression/177444
**Category:** Elasticsearch
**Created:** [April 18, 2019, 10:25am UTC](https://discuss.elastic.co/t/using-regular-expression/177444 "2019-04-18T10:25:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Ummugulsum\_Goktas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ummugulsum_goktas/32/44388_2.png) [@Ummugulsum\_Goktas](https://discuss.elastic.co/u/Ummugulsum_Goktas)
#### Post date: [April 18, 2019, 10:25am UTC](https://discuss.elastic.co/t/using-regular-expression/177444/1 "2019-04-18T10:25:54Z")

</div>

I have a question regarding a query.

I have a file named 'file121.docx', I am using the following query to search for the file:

```
GET demoindex/_search
{
  "_source": "documentName", 
  "query": {
    "regexp": {
      "documentName":{
       "value": "file121.docx"
       }
    }
  }
}

```

The query above does not return a result?

However when I run the query with a wildcard like so it returns the file?

```
GET demoindex/_search
{
  "_source": "documentName", 
  "query": {
    "regexp": {
      "documentName":{
       "value": "file121.*"
       }
    }
  }
}

```

When I run the same query with the full file name against another file from the list of files in my elastic search index it returns the result fine...

For Example:

```
GET demoindex/_search
{
  "_source": "documentName", 
  "query": {
    "regexp": {
      "documentName":{
       "value": "yjmnsdfs.exe"
      }
    }
  }
}

```

It seems to be an issue with files that contain numeric characters in the filename?

Does anybody have a solution for this?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 18, 2019, 12:54pm UTC](https://discuss.elastic.co/t/using-regular-expression/177444/2 "2019-04-18T12:54:10Z")

</div>

Note that regex queries might be slow.  
But if you really want to use this, you should define a proper mapping with a keyword or lowercase analyzer.

---

<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: [May 16, 2019, 12:54pm UTC](https://discuss.elastic.co/t/using-regular-expression/177444/3 "2019-05-16T12:54:15Z")

</div>

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