# Search problem with query\_string and special characters

**URL:** <https://discuss.elastic.co/t/search-problem-with-query-string-and-special-characters/36366>\
**Category:** Elasticsearch\
**Created:** [December 4, 2015, 9:43am UTC](https://discuss.elastic.co/t/search-problem-with-query-string-and-special-characters/36366 "2015-12-04T09:43:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davteje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davteje/32/25495_2.png) [@davteje](https://discuss.elastic.co/u/davteje)\
**Post date:** [December 4, 2015, 9:43am UTC](https://discuss.elastic.co/t/search-problem-with-query-string-and-special-characters/36366/1 "2015-12-04T09:43:02Z")

</div>

Searching with **AND operator** and **special characters** with **query\_string** it returns more results than I expect.

Having two documents with one field called _searchField_, with the next values:

- _First document_, value: **AAA{BBB}CCC**
- _Second document_, value: **AAA{BBB}DDD**

I have the following results:

- _First case:_ Returns **both documents** searching for the value: **AAA{BBB}CCC**
- _Second case:_ Returns **only the first document** searching for the value: **AAA BBB CCC**

I guess both queries should return only the first document as the search is done with AND operator.

The query used in the first case is the following:

```
"query":{
    "filtered":{
        "query":{
            "bool":{
                "must":[{
                    "query_string":{
                        "query":"AAA\{BBB\}CCC*",
                        "fields":["searchField"],
                        "analyze_wildcard":true,
                        "default_operator":"and"
                    }
                }]
            }
        }
    }
}

```

I'm using Java with JestClient client.  
The reason why I use the bool query is that is created dynamically so it could have more parameters.

This "issue" happens with several special characters. Not sure if I could be doing something wrong.

Thank you very much!

---

<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, 11:32pm UTC](https://discuss.elastic.co/t/search-problem-with-query-string-and-special-characters/36366/2 "2017-07-05T23:32:39Z")

</div>


