Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add overlapping, before, after filters to intervals query #38999

Merged
merged 1 commit into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/reference/query-dsl/intervals-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,14 @@ Produces intervals that are contained by an interval from the filter rule
Produces intervals that do not contain an interval from the filter rule
`not_contained_by`::
Produces intervals that are not contained by an interval from the filter rule
`overlapping`::
Produces intervals that overlap with an interval from the filter rule
`not_overlapping`::
Produces intervals that do not overlap with an interval from the filter rule
`before`::
Produces intervals that appear before an interval from the filter role
`after`::
Produces intervals that appear after an interval from the filter role

[[interval-script-filter]]
==== Script filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,68 @@ setup:
query: "there"
ordered: false
- match: { hits.total.value: 1 }

---
"Test overlapping":
- skip:
version: " - 7.9.99"
reason: "Implemented in 7.1"
- do:
search:
index: test
body:
query:
intervals:
text:
match:
query: "cold outside"
ordered: true
filter:
overlapping:
match:
query: "baby there"
ordered: false
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "3" }

---
"Test before":
- skip:
version: " - 7.9.99"
reason: "Implemented in 7.1"
- do:
search:
index: test
body:
query:
intervals:
text:
match:
query: "cold"
filter:
before:
match:
query: "outside"
- match: { hits.total.value: 2 }

---
"Test after":
- skip:
version: " - 7.9.99"
reason: "Implemented in 7.1"
- do:
search:
index: test
body:
query:
intervals:
text:
match:
query: "cold"
filter:
after:
match:
query: "outside"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "4" }

Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,14 @@ public IntervalsSource filter(IntervalsSource input, QueryShardContext context,
return Intervals.notContaining(input, filterSource);
case "not_contained_by":
return Intervals.notContainedBy(input, filterSource);
case "overlapping":
return Intervals.overlapping(input, filterSource);
case "not_overlapping":
return Intervals.nonOverlapping(input, filterSource);
case "before":
return Intervals.before(input, filterSource);
case "after":
return Intervals.after(input, filterSource);
default:
throw new IllegalArgumentException("Unknown filter type [" + type + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public void testUnknownField() throws IOException {
}

private static final String[] filters = new String[]{
"containing", "contained_by", "not_containing", "not_contained_by", "not_overlapping"
"containing", "contained_by", "not_containing", "not_contained_by",
"overlapping", "not_overlapping", "before", "after"
};

private IntervalsSourceProvider.IntervalFilter createRandomFilter() {
Expand Down