# Using wildcards and boolean operators for keyword fields with whitespaces

**URL:** <https://discuss.elastic.co/t/using-wildcards-and-boolean-operators-for-keyword-fields-with-whitespaces/84547>\
**Category:** Elasticsearch\
**Created:** [May 4, 2017, 11:44am UTC](https://discuss.elastic.co/t/using-wildcards-and-boolean-operators-for-keyword-fields-with-whitespaces/84547 "2017-05-04T11:44:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sawa](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@sawa](https://discuss.elastic.co/u/sawa)\
**Post date:** [May 4, 2017, 11:44am UTC](https://discuss.elastic.co/t/using-wildcards-and-boolean-operators-for-keyword-fields-with-whitespaces/84547/1 "2017-05-04T11:44:23Z")

</div>

Is it possible to write a single elasticsearch query to search for keyword fields with whitespaces, wildcards and boolean operators?  
For my usecase I would like to use the `query_string`, because i will use it as an userinterface and the query will be defined by the user.

### Reproduce:

For example if my dataset consist of **"Hello World", "Wrong Field", "Failed"** and I try to get only **"Hello World"**.

```auto
curl -XPUT 'localhost:9200/example_index?pretty' -H 'Content-Type: application/json'
curl -XPOST 'localhost:9200/example_index/_bulk?pretty' -H 'Content-Type: application/json' -d'
{ "index": { "_index": "example_index", "_type": "test-data" } }
{ "@timestamp": "2017-05-01T10:00:00.000Z", "text": "Hello World" }
{ "index": { "_index": "example_index", "_type": "test-data" } }
{ "@timestamp": "2017-05-01T10:00:00.000Z", "text": "Wrong Field" }
{ "index": { "_index": "example_index", "_type": "test-data" } }
{ "@timestamp": "2017-05-01T10:00:00.000Z", "text": "Failed" }
'

```

For this query I get the **"Wrong Field"** , but I expect **"Hello World"**.

```auto
curl -XGET 'localhost:9200/example_index/_search?pretty' -H 'Content-Type: application/json' -d'                                                                                             
{
  "query": {
    "query_string": {
      "query": "text.keyword:(Hello W*) AND text.keyword:(*d)"
    }
  }
}
'

```

---

<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:** [June 1, 2017, 11:47am UTC](https://discuss.elastic.co/t/using-wildcards-and-boolean-operators-for-keyword-fields-with-whitespaces/84547/2 "2017-06-01T11:47:03Z")

</div>

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