Skip to content

Commit

Permalink
addressing PR comments - adding score validation in yml tests and ens…
Browse files Browse the repository at this point in the history
…uring different values in mutation tests
  • Loading branch information
pmpailis committed Sep 26, 2024
1 parent ff05d13 commit ec9c725
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.elasticsearch.common.io.stream.Writeable.Reader;
import org.elasticsearch.test.AbstractWireSerializingTestCase;
import org.elasticsearch.test.ESTestCase;

import java.io.IOException;

Expand Down Expand Up @@ -62,16 +63,16 @@ protected RRFRankDoc mutateInstance(RRFRankDoc instance) throws IOException {

switch (randomInt(6)) {
case 0:
doc = randomNonNegativeInt();
doc = randomValueOtherThan(doc, ESTestCase::randomNonNegativeInt);
break;
case 1:
shardIndex = shardIndex == -1 ? randomNonNegativeInt() : -1;
break;
case 2:
score = randomFloat();
score = randomValueOtherThan(score, ESTestCase::randomFloat);
break;
case 3:
rankConstant = randomIntBetween(1, 100);
rankConstant = randomValueOtherThan(rankConstant, () -> randomIntBetween(1, 100));
break;
case 4:
rank = rank == NO_RANK ? randomIntBetween(1, 10000) : NO_RANK;
Expand All @@ -83,7 +84,7 @@ protected RRFRankDoc mutateInstance(RRFRankDoc instance) throws IOException {
break;
case 6:
for (int i = 0; i < queries; i++) {
scores[i] = randomFloat();
scores[i] = randomValueOtherThan(scores[i], ESTestCase::randomFloat);
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
setup:
- skip:
features: close_to

- requires:
cluster_features: 'rrf_retriever_composition_supported'
reason: 'test requires rrf retriever composition support'
Expand Down Expand Up @@ -168,8 +171,14 @@ setup:
- match: { hits.total.value : 4 }
- length: { hits.hits : 3 }
- match: { hits.hits.0._id: "2" }
# score for doc 2 is (1/12 + 1/12)
- close_to: {hits.hits.0._score: {value: 0.1666, error: 0.001}}
- match: { hits.hits.1._id: "3" }
# score for doc 3 is (1/13 + 1/13)
- close_to: {hits.hits.1._score: {value: 0.1538, error: 0.001}}
- match: { hits.hits.2._id: "4" }
# score for doc 4 is (1/14 + 1/14)
- close_to: {hits.hits.2._score: {value: 0.1428, error: 0.001}}

---
"Standard pagination outside rank_window_size":
Expand Down Expand Up @@ -387,6 +396,8 @@ setup:
- match: { hits.total.value : 4 }
- length: { hits.hits : 1 }
- match: { hits.hits.0._id: "3" }
# score for doc 3 is (1/13 + 1/13)
- close_to: {hits.hits.0._score: {value: 0.1538, error: 0.001}}


---
Expand Down Expand Up @@ -501,7 +512,11 @@ setup:
- match: { hits.total.value : 4 }
- length: { hits.hits : 2 }
- match: { hits.hits.0._id: "1" }
# score for doc 1 is (1/11 + 1/13)
- close_to: {hits.hits.0._score: {value: 0.1678, error: 0.001}}
- match: { hits.hits.1._id: "4" }
# score for doc 4 is (1/11 + 1/14)
- close_to: {hits.hits.1._score: {value: 0.1623, error: 0.001}}

- do:
search:
Expand Down Expand Up @@ -608,7 +623,11 @@ setup:
- match: { hits.total.value : 4 }
- length: { hits.hits : 2 }
- match: { hits.hits.0._id: "3" }
# score for doc 3 is (1/12 + 1/13)
- close_to: {hits.hits.0._score: {value: 0.1602, error: 0.001}}
- match: { hits.hits.1._id: "2" }
# score for doc 2 is (1/12 + 1/14)
- close_to: {hits.hits.1._score: {value: 0.1547, error: 0.001}}

---
"Pagination within interleaved results, different result set sizes, rank_window_size covering all results":
Expand Down Expand Up @@ -706,7 +725,11 @@ setup:
- match: { hits.total.value : 5 }
- length: { hits.hits : 2 }
- match: { hits.hits.0._id: "1" }
# score for doc 1 is (1/12 + 1/13)
- close_to: {hits.hits.0._score: {value: 0.1602, error: 0.001}}
- match: { hits.hits.1._id: "4" }
# score for doc 4 is (1/11)
- close_to: {hits.hits.1._score: {value: 0.0909, error: 0.001}}

- do:
search:
Expand Down Expand Up @@ -797,7 +820,11 @@ setup:
- match: { hits.total.value : 5 }
- length: { hits.hits : 2 }
- match: { hits.hits.0._id: "5" }
# score for doc 5 is (1/11)
- close_to: {hits.hits.0._score: {value: 0.0909, error: 0.001}}
- match: { hits.hits.1._id: "3" }
# score for doc 3 is (1/12)
- close_to: {hits.hits.1._score: {value: 0.0833, error: 0.001}}

- do:
search:
Expand Down Expand Up @@ -888,6 +915,8 @@ setup:
- match: { hits.total.value: 5 }
- length: { hits.hits: 1 }
- match: { hits.hits.0._id: "2" }
# score for doc 2 is (1/14)
- close_to: {hits.hits.0._score: {value: 0.0714, error: 0.001}}


---
Expand Down Expand Up @@ -988,7 +1017,11 @@ setup:
- match: { hits.total.value : 5 }
- length: { hits.hits : 2 }
- match: { hits.hits.0._id: "4" }
# score for doc 4 is (1/11)
- close_to: {hits.hits.0._score: {value: 0.0909, error: 0.001}}
- match: { hits.hits.1._id: "5" }
# score for doc 5 is (1/11)
- close_to: {hits.hits.1._score: {value: 0.0909, error: 0.001}}

- do:
search:
Expand Down

0 comments on commit ec9c725

Please sign in to comment.