# Intervals search with complicated before/after requirements

**URL:** <https://discuss.elastic.co/t/intervals-search-with-complicated-before-after-requirements/224850>\
**Category:** Elasticsearch\
**Created:** [March 24, 2020, 1:30pm UTC](https://discuss.elastic.co/t/intervals-search-with-complicated-before-after-requirements/224850 "2020-03-24T13:30:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew-matteson](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@andrew-matteson](https://discuss.elastic.co/u/andrew-matteson)\
**Post date:** [March 24, 2020, 1:30pm UTC](https://discuss.elastic.co/t/intervals-search-with-complicated-before-after-requirements/224850/1 "2020-03-24T13:30:51Z")

</div>

I'm trying to develop a query that's based on several interval searches. One of the searches needs to exclude intervals containing a particular word if it appears in the interval, within the 10 preceding words before the interval, or the 10 words after.

The first is easy to handle with a `not_contained_by` filter. However, I can't think of how to formulate a query that works as a `not_after` or `not_before` query that searches over the specified range.

Any ideas?

---

<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:** [April 21, 2020, 1:30pm UTC](https://discuss.elastic.co/t/intervals-search-with-complicated-before-after-requirements/224850/2 "2020-04-21T13:30:56Z")

</div>

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