# Complex Proximity/Nested/exact-match Queries in Elasticsearch

**URL:** <https://discuss.elastic.co/t/complex-proximity-nested-exact-match-queries-in-elasticsearch/307998>\
**Category:** Elasticsearch\
**Created:** [June 23, 2022, 11:33am UTC](https://discuss.elastic.co/t/complex-proximity-nested-exact-match-queries-in-elasticsearch/307998 "2022-06-23T11:33:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaivikram](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaivikram/32/107491_2.png) [@jaivikram](https://discuss.elastic.co/u/jaivikram)\
**Post date:** [June 23, 2022, 11:33am UTC](https://discuss.elastic.co/t/complex-proximity-nested-exact-match-queries-in-elasticsearch/307998/1 "2022-06-23T11:33:34Z")

</div>

I am looking for proximity (and nested proximity as well) between multiple hetrogeneous groups

By hetrogeneous I mean the token in the groups can be:

- term and term
- term and phrase
- phrase and phrase
- term and wildcard
- phrase and wildcard
- wildcard and wildcard
- term and phrase and wildcard

Some examples of the search criteria from user's perspective are:

- `((sfo OR “serious fraud office”) w/50 investigat*)`
- `(potential w/30 (violation*))`
- `(fcpa or "foreign corrupt practices act")`
- `((improper W/3 payment*) W/20 investigat*)`
- `((corrupt* W/5 payment*) W/20 investigat*)`
- `((sec OR "securities and exchange commission") w/20 (fcpa OR foreign corrupt practices act))`
- `(brib* W/20 arrest*)`
- `(((fcpa OR "foreign corrupt practices act") w/50 subpoe*) W/20 (violat* OR investigat*))`
- `((internal investigat*) W/50 (fcpa OR “foreign corrupt practices act” OR corrupt*))`

Documents are legal documents with size anywhere between 10,000 chars to 4Million chars.

I have tried query\_string, simple\_query\_string, match, match\_phrase, span\_near as well as intervals, but to no luck.

The main unresolved issues are:

- How to do wildcard in proximity searches ?
- How to handle nested proximity searches ?

Any help will be greatly appreicated.

---

<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 21, 2022, 11:34am UTC](https://discuss.elastic.co/t/complex-proximity-nested-exact-match-queries-in-elasticsearch/307998/2 "2022-07-21T11:34:24Z")

</div>

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