Skip to content

Commit

Permalink
HUZZAH! Local tests now pass.
Browse files Browse the repository at this point in the history
  • Loading branch information
kderusso committed Oct 24, 2024
1 parent 3800de2 commit 1cfe1b7
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ protected void doToXContent(XContentBuilder builder, Params params) throws IOExc

@Override
protected boolean doEquals(Object o) {
return in.equals(o);
// Handle the edge case where we need to unwrap the incoming retriever
if (o instanceof RetrieverBuilderWrapper<?> wrapper) {
return in.doEquals(wrapper.in);
} else {
return in.doEquals(o);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void doToXContent(XContentBuilder builder, Params params) throws IOExcept

@Override
public boolean doEquals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TestRetrieverBuilder that = (TestRetrieverBuilder) o;
return Objects.equals(value, that.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,67 +293,67 @@ setup:

- match: { hits.total.value: 3 }
- match: { hits.hits.0._id: foo }
- match: { hits.hits.0._score: 1.7014124430769804E38
- match: { hits.hits.1._score: 0 }
- match: { hits.hits.2._score: 0 }

- do:
headers:
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
Content-Type: application/json
search:
index: test-index1
body:
retriever:
rule:
match_criteria:
foo: foo
bar: bar
ruleset_ids:
test-ruleset
retriever:
standard:
query:
query_string:
query: bar
rank_window_size: 2

- match: { hits.total.value: 3 }
- match: { hits.hits.0._id: foo }
- match: { hits.hits.0._score: 1.7014124E38 }
- match: { hits.hits.1._id: foo2 }
- match: { hits.hits.1._score: 1.7014122E38 }
- match: { hits.hits.2._id: bar_no_rule }
- match: { hits.hits.2._score: 0 }

- do:
headers:
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
Content-Type: application/json
search:
index: test-index1
body:
retriever:
rule:
match_criteria:
foo: foo
bar: bar
ruleset_ids:
test-ruleset
retriever:
standard:
query:
query_string:
query: bar
rank_window_size: 10

- match: { hits.total.value: 3 }
- match: { hits.hits.0._id: foo }
- match: { hits.hits.0._score: 1.7014124E38 }
- match: { hits.hits.1._id: foo2 }
- match: { hits.hits.1._score: 1.7014122E38 }
- match: { hits.hits.2._id: bar_no_rule }
- match: { hits.hits.2._score: 0.87832844 }
- match: { hits.hits.0._score: 1.7014124E38 }
- match: { hits.hits.1._score: 0 }
- match: { hits.hits.2._score: 0 }

- do:
headers:
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
Content-Type: application/json
search:
index: test-index1
body:
retriever:
rule:
match_criteria:
foo: foo
bar: bar
ruleset_ids:
test-ruleset
retriever:
standard:
query:
query_string:
query: bar
rank_window_size: 2

- match: { hits.total.value: 3 }
- match: { hits.hits.0._id: foo }
- match: { hits.hits.0._score: 1.7014124E38 }
- match: { hits.hits.1._id: foo2 }
- match: { hits.hits.1._score: 1.7014122E38 }
- match: { hits.hits.2._id: bar_no_rule }
- match: { hits.hits.2._score: 0 }

- do:
headers:
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
Content-Type: application/json
search:
index: test-index1
body:
retriever:
rule:
match_criteria:
foo: foo
bar: bar
ruleset_ids:
test-ruleset
retriever:
standard:
query:
query_string:
query: bar
rank_window_size: 10

- match: { hits.total.value: 3 }
- match: { hits.hits.0._id: foo }
- match: { hits.hits.0._score: 1.7014124E38 }
- match: { hits.hits.1._id: foo2 }
- match: { hits.hits.1._score: 1.7014122E38 }
- match: { hits.hits.2._id: bar_no_rule }
- match: { hits.hits.2._score: 0.87832844 }

---
"query rules will error if sorting by anything other than score":
Expand Down Expand Up @@ -404,7 +404,7 @@ setup:
explain: true

- match: { hits.hits.0._id: foo }
- match: { hits.hits.0._explanation.value: 1.7014124430769804E38 }
- match: { hits.hits.0._explanation.value: 1.7014124E38 }
- match: { hits.hits.0._explanation.description: "query rules evaluated rules from rulesets [test-ruleset] and match criteria {bar=bar, foo=foo}" }
- match: { hits.hits.0._explanation.details.0.value: 1 }
- match: { hits.hits.0._explanation.details.0.description: "doc [0] with an original score of [1.7014124E38] is at rank [1] from the following source queries." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public void doToXContent(XContentBuilder builder, Params params) throws IOExcept
builder.mapContents(matchCriteria);
builder.endObject();
builder.field(RETRIEVER_FIELD.getPreferredName(), innerRetrievers.getFirst().retriever());
// We need to explicitly include this here as it's not propagated by the wrapper
builder.field(RANK_WINDOW_SIZE_FIELD.getPreferredName(), rankWindowSize);
}

@Override
Expand Down

0 comments on commit 1cfe1b7

Please sign in to comment.