# Filter to select lines that contain a certain word which begins with "ANS" and which can end with a series of numbers or letters

**URL:** <https://discuss.elastic.co/t/filter-to-select-lines-that-contain-a-certain-word-which-begins-with-ans-and-which-can-end-with-a-series-of-numbers-or-letters/279259>\
**Category:** Elasticsearch\
**Created:** [July 21, 2021, 12:26pm UTC](https://discuss.elastic.co/t/filter-to-select-lines-that-contain-a-certain-word-which-begins-with-ans-and-which-can-end-with-a-series-of-numbers-or-letters/279259 "2021-07-21T12:26:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boubou](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@boubou](https://discuss.elastic.co/u/boubou)\
**Post date:** [July 21, 2021, 12:26pm UTC](https://discuss.elastic.co/t/filter-to-select-lines-that-contain-a-certain-word-which-begins-with-ans-and-which-can-end-with-a-series-of-numbers-or-letters/279259/1 "2021-07-21T12:26:01Z")

</div>

Hello everybody,

I would like to create a filter who select lines that contain a certain word which begins with "ANS" and which can end with a series of numbers or letters.

For example, I have a Tag who contains these lines :

```auto
ANS2832E Incremental by snapshot difference failed
BM Spectrum Protect Backup-Archive Client Version 8, Release 1, Level 4.0

```

i would like make a regex like this :

![image](https://us1.discourse-cdn.com/elastic/original/3X/3/2/328f092415557a8c93159304d6c8e1c5317502fe.png)

but it not work... Can you help me please ?  
Thanks a lot ! 😃

---

<div class="post-metadata">

**Author:** ![corey.robertson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corey.robertson/32/54611_2.png) [@corey.robertson](https://discuss.elastic.co/u/corey.robertson)\
**Post date:** [July 21, 2021, 1:31pm UTC](https://discuss.elastic.co/t/filter-to-select-lines-that-contain-a-certain-word-which-begins-with-ans-and-which-can-end-with-a-series-of-numbers-or-letters/279259/2 "2021-07-21T13:31:02Z")

</div>

Hi @boubou

I think you will need to do a regex query instead of match\_phrase

Something like

```auto
POST test/_search
{
  "query": {
    "regexp": {
      "logMessage.keyword": {
        "value": "ANS.*"
      }
    }
  }
}

```

---

<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:** [August 18, 2021, 1:31pm UTC](https://discuss.elastic.co/t/filter-to-select-lines-that-contain-a-certain-word-which-begins-with-ans-and-which-can-end-with-a-series-of-numbers-or-letters/279259/3 "2021-08-18T13:31:28Z")

</div>

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