# Unexpected character ~ with proximity query

**URL:** <https://discuss.elastic.co/t/unexpected-character-with-proximity-query/73961>\
**Category:** Elasticsearch\
**Created:** [February 4, 2017, 10:55pm UTC](https://discuss.elastic.co/t/unexpected-character-with-proximity-query/73961 "2017-02-04T22:55:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WillB](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/willb/32/15208_2.png) [@WillB](https://discuss.elastic.co/u/WillB)\
**Post date:** [February 4, 2017, 10:55pm UTC](https://discuss.elastic.co/t/unexpected-character-with-proximity-query/73961/1 "2017-02-04T22:55:01Z")

</div>

Hi,  
I'm trying to create a proximity query using the docs [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_proximity_searches)

I get an error "reason":"Unexpected character ('~' (code 126)): was expecting comma to separate Object entries" but as far as I can tell, I'm formatting it as specified in the documentation.

The goal is to create a query string proximity query with results having the words "baboon" and "sorry" with a max distance of 5. I can do this with a match phrase and slop, but would like to see how it is done with query string proximity.

Elasticsearch 5.0

```
curl -X POST -H "Cache-Control: no-cache" -d '{
	"query": {
		"query_string": {
			"fields": ["spoken_words"],
			"query": "baboon sorry"~5
		}
	}
}' "http://localhost:9200/simpsons/_search"
```

---

<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:** [March 4, 2017, 10:55pm UTC](https://discuss.elastic.co/t/unexpected-character-with-proximity-query/73961/2 "2017-03-04T22:55:11Z")

</div>

Closed on March 4, 2017, 10:55pm UTC

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