# Regex search

**URL:** <https://discuss.elastic.co/t/regex-search/54477>\
**Category:** Elasticsearch\
**Created:** [June 30, 2016, 11:07pm UTC](https://discuss.elastic.co/t/regex-search/54477 "2016-06-30T23:07:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karlis\_Melderis](https://avatars.discourse-cdn.com/v4/letter/k/bbce88/32.png) [@Karlis\_Melderis](https://discuss.elastic.co/u/Karlis_Melderis)\
**Post date:** [June 30, 2016, 11:07pm UTC](https://discuss.elastic.co/t/regex-search/54477/1 "2016-06-30T23:07:36Z")

</div>

Hello, All

first I'm beginner with ES so sorry if my question will sound stupid.

I have problem to search file path with regex in query\_string. (unfortunately due to way how app is written that's my only option)  
seems that / in string is killing search as I can easily remove one char from my "word" and it will be found but if use string that is starting straight after / I get nothing.  
same time if I use regexp query I get my data.

cs\_uri\_stem field contains:  
/some/path/to/file.txt

```
Doesn't work (similar to Graylog generated search):
    curl -XPOST "http://10.0.0.20:9200/_all/_search" -d'
    {
      "from": 0,
      "size": 100,
      "query": {
        "filtered": {
          "query": {
            "query_string": {
              "query": "gl2_source_input:577281f853325c6c3ee5a3e4 AND cs_uri_stem:/.*file.*/",
              "allow_leading_wildcard": true
            }
          },
          "filter": {
            "bool": {
              "must": {
                "range": {
                  "timestamp": {
                    "from": "2016-06-30 22:26:03.475",
                    "to": "2016-06-30 22:31:03.476",
                    "include_lower": true,
                    "include_upper": true
                  }
                }
              }
            }
          }
        }
      },
      "sort": [
        {
          "timestamp": {
            "order": "desc"
          }
        }
      ]
    }'

    Works:
    curl -XPOST "http://10.0.0.20:9200/_all/_search" -d'
    {
      "from": 0,
      "size": 100,
      "query": {
        "filtered": {
          "query": {
        "regexp": {
            "cs_uri_stem": {
                "value": ".*file.*"
            }
        }
          },
          "filter": {
            "bool": {
              "must": {
                "range": {
                  "timestamp": {
                    "from": "2016-06-30 22:26:03.475",
                    "to": "2016-06-30 22:31:03.476",
                    "include_lower": true,
                    "include_upper": true
                  }
                }
              }
            }
          }
        }
      },
      "sort": [
        {
          "timestamp": {
            "order": "desc"
          }
        }
      ]
    }'
```

---

<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:** [July 1, 2016, 6:53am UTC](https://discuss.elastic.co/t/regex-search/54477/2 "2016-07-01T06:53:36Z")

</div>

Please format your code with `</>`.

---

<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:39pm UTC](https://discuss.elastic.co/t/regex-search/54477/3 "2017-07-05T22:39:03Z")

</div>


