Skip to content

Commit

Permalink
Fix text expansion yaml test
Browse files Browse the repository at this point in the history
  • Loading branch information
kderusso committed Mar 29, 2024
1 parent 89b2574 commit 9c46626
Showing 1 changed file with 93 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ teardown:
index: index-with-sparse-vector
body:
query:
sparse_vector:
text_expansion:
ml.tokens:
model_id: text_expansion_model
model_text: "octopus comforter smells"
Expand All @@ -146,15 +146,15 @@ teardown:
---
"Test text expansion search with pruning config":
- skip:
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"
version: " - 8.12.99"
reason: "pruning introduced in 8.13.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
text_expansion:
ml.tokens:
model_id: text_expansion_model
model_text: "octopus comforter smells"
Expand All @@ -167,14 +167,14 @@ teardown:
---
"Test named, boosted text expansion search with pruning config":
- skip:
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"
version: " - 8.12.99"
reason: "pruning introduced in 8.13.0"
- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
text_expansion:
ml.tokens:
model_id: text_expansion_model
model_text: "octopus comforter smells"
Expand All @@ -190,7 +190,7 @@ teardown:
index: index-with-sparse-vector
body:
query:
sparse_vector:
text_expansion:
ml.tokens:
model_id: text_expansion_model
model_text: "octopus comforter smells"
Expand All @@ -207,15 +207,15 @@ teardown:
---
"Test text expansion search with default pruning config":
- skip:
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"
version: " - 8.12.99"
reason: "pruning introduced in 8.13.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
text_expansion:
ml.tokens:
model_id: text_expansion_model
model_text: "octopus comforter smells"
Expand All @@ -226,15 +226,15 @@ teardown:
---
"Test text expansion search with weighted tokens rescoring only pruned tokens":
- skip:
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"
version: " - 8.12.99"
reason: "pruning introduced in 8.13.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
text_expansion:
ml.tokens:
model_id: text_expansion_model
model_text: "octopus comforter smells"
Expand All @@ -243,3 +243,82 @@ teardown:
tokens_weight_threshold: 0.4
only_score_pruned_tokens: true
- match: { hits.total.value: 0 }

---
"Test weighted tokens search":
- skip:
version: " - 8.12.99"
reason: "weighted token search introduced in 8.13.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
weighted_tokens:
ml.tokens:
tokens: [{"the": 1.0}, {"comforter":1.0}, {"smells":1.0}, {"bad": 1.0}]
pruning_config:
tokens_freq_ratio_threshold: 1
tokens_weight_threshold: 0.4
only_score_pruned_tokens: false
- match: { hits.total.value: 5 }
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test weighted tokens search with default pruning config":
- skip:
version: " - 8.12.99"
reason: "weighted token search introduced in 8.13.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
weighted_tokens:
ml.tokens:
tokens: [{"the": 1.0}, {"comforter":1.0}, {"smells":1.0}, {"bad": 1.0}]
pruning_config: {}
- match: { hits.total.value: 5 }
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test weighted tokens search only scoring pruned tokens":
- skip:
version: " - 8.12.99"
reason: "weighted token search introduced in 8.13.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
weighted_tokens:
ml.tokens:
tokens: [{"the": 1.0}, {"comforter":1.0}, {"smells":1.0}, {"bad": 1.0}]
pruning_config:
tokens_freq_ratio_threshold: 4
tokens_weight_threshold: 0.4
only_score_pruned_tokens: true
- match: { hits.total.value: 0 }

---
"Test weighted tokens search that prunes tokens based on frequency":
- skip:
version: " - 8.12.99"
reason: "weighted token search introduced in 8.13.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
weighted_tokens:
ml.tokens:
tokens: [{"the": 1.0}, {"octopus":1.0}, {"comforter":1.0}, {"is": 1.0}, {"the": 1.0}, {"best": 1.0}, {"of": 1.0}, {"the": 1.0}, {"bunch": 1.0}]
pruning_config:
tokens_freq_ratio_threshold: 3
tokens_weight_threshold: 0.4
only_score_pruned_tokens: true
- match: { hits.total.value: 0 }

0 comments on commit 9c46626

Please sign in to comment.