# Wildcard / regexp in a phrase which has space

**URL:** <https://discuss.elastic.co/t/wildcard-regexp-in-a-phrase-which-has-space/117962>\
**Category:** Elasticsearch\
**Created:** [February 1, 2018, 8:21am UTC](https://discuss.elastic.co/t/wildcard-regexp-in-a-phrase-which-has-space/117962 "2018-02-01T08:21:21Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![anoopvalluthadam](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anoopvalluthadam/32/30286_2.png) [@anoopvalluthadam](https://discuss.elastic.co/u/anoopvalluthadam)\
**Post date:** [February 2, 2018, 2:28am UTC](https://discuss.elastic.co/t/wildcard-regexp-in-a-phrase-which-has-space/117962/16 "2018-02-02T02:28:59Z")

</div>

It has issues.

```
DELETE test
PUT test
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "filter": [
            "lowercase", "ngram"
          ]
        }
      },
      "filter": {
        "ngram": {
          "type": "edge_ngram",
          "min_gram": 1,
          "max_gram": 20,
          "token_chars": [
            "letter",
            "digit"
          ]
        }
      }
    }
  },
  "mappings": {
    "doc": {
      "properties": {
        "text": {
          "type": "text",
          "analyzer": "my_analyzer"
        }
      }
    }
  }
}
PUT test/doc/1
{
  "text": "2 #Quick Foxes lived and died"
}
PUT test/doc/2
{
  "text": "2 #Quick Foxes lived died"
}
PUT test/doc/3
{
  "text": "2 #Quick Foxes lived died and resurrected their wys "
}
PUT test/doc/4
{
  "text": """Sports Report:
Cricket - The Adelaide Strikers have blasted their way back to the top of the Big Bash ladder, after beating the Melbourne Stars."""
}

```

And the query is

```
GET test/_search
{
  "query": {
    "match_phrase": {
      "text": "th wa"
    }
  }
}

```

Result is

```
{
  "took": 0,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 4.558014,
    "hits": [
      {
        "_index": "test",
        "_type": "doc",
        "_id": "4",
        "_score": 4.558014,
        "_source": {
          "text": "Sports Report:\nCricket - The Adelaide Strikers have blasted their way back to the top of the Big Bash ladder, after beating the Melbourne Stars."
        }
      },
      {
        "_index": "test",
        "_type": "doc",
        "_id": "3",
        "_score": 3.9283106,
        "_source": {
          "text": "2 #Quick Foxes lived died and resurrected their wys "
        }
      }
    ]
  }
}

```

of-course the second one is wrong.

becuse query was

> th wa

so it should not bring anything with

> wy

isn't it?

---

_[View the full topic](https://discuss.elastic.co/t/wildcard-regexp-in-a-phrase-which-has-space/117962)._
