# Phrase proximity with simple\_query\_string and NEST

**URL:** <https://discuss.elastic.co/t/phrase-proximity-with-simple-query-string-and-nest/275002>\
**Category:** Elasticsearch\
**Created:** [June 4, 2021, 6:14pm UTC](https://discuss.elastic.co/t/phrase-proximity-with-simple-query-string-and-nest/275002 "2021-06-04T18:14:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DMinovski](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@DMinovski](https://discuss.elastic.co/u/DMinovski)\
**Post date:** [June 4, 2021, 6:14pm UTC](https://discuss.elastic.co/t/phrase-proximity-with-simple-query-string-and-nest/275002/1 "2021-06-04T18:14:56Z")

</div>

I'm using the `simple_query_string` with the tilde `~` operator to specify proximity between words in a phrase, and it works. The `simple query` has other functions that `match` doesn't provide.

```auto
     {
               "simple_query_string":{

                  "query":"\"small demonstration\"~10",
                  "fields":[
                     "data"
                  ]
               }
    }

```

But, using `"small demonstration"~10` or `"\"small demonstration\"~10"` in an equivalent NEST query doesn't add proximity search.

```auto
    m => m
		.SimpleQueryString(s => s
						.Query("small demonstration"~10)
						.Fields(f => f
						.Fields(emptyFieldArray))
						)

```

There can be multiple phrases using double-quotes, `"phrase-1" other words "phrase-2"`. Can I add the tilde character to single or multiple phrases with NEST using the `simple_query_string`?

---

<div class="post-metadata">

**Author:** ![DMinovski](https://avatars.discourse-cdn.com/v4/letter/d/5fc32e/32.png) [@DMinovski](https://discuss.elastic.co/u/DMinovski)\
**Post date:** [June 4, 2021, 6:33pm UTC](https://discuss.elastic.co/t/phrase-proximity-with-simple-query-string-and-nest/275002/2 "2021-06-04T18:33:20Z")

</div>

In the `Fields` method, at least one field needs to be specified.

```auto
.Fields(f => f
.Fields(specifyAtLeastOneFieldArray))

```

When the field array is empty, Elastic searches through all the fields, but it seems that it doesn't make use of the `proximity` character.

---

<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 2, 2021, 6:34pm UTC](https://discuss.elastic.co/t/phrase-proximity-with-simple-query-string-and-nest/275002/3 "2021-07-02T18:34:02Z")

</div>

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