Skip to content

Commit

Permalink
Add more yaml cases
Browse files Browse the repository at this point in the history
  • Loading branch information
kderusso committed Apr 1, 2024
1 parent 8cd348e commit db44c87
Showing 1 changed file with 120 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,48 @@ setup:
wait_for: started

---
"Test sparse vector search":
Test that sparse vector search requires a model ID and vector dimensions:
- do:
catch: /\[sparse_vector\] requires one of \[model_id\], or \[vector_dimensions\]/
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
ml.tokens:
model_text: "the octopus comforter smells"

---
Test that sparse vector search will not allow both a model ID and vector dimensions:
- do:
catch: /\[sparse_vector\] requires one of \[model_id\], or \[vector_dimensions\]/
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
ml.tokens:
model_id: my_sparse_vector_model
vector_dimensions:
the: 1
comforter: 1
smells: 1
bad: 1

---
"Test that sparse vector search requires model text if model id is specified":
- do:
catch: /\[sparse_vector\] requires \[model_text\] when \[model_id\] is specified/
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
ml.tokens:
model_id: my_sparse_vector_model

---
"Test sparse vector search with a model ID":
- do:
search:
index: index-with-sparse-vector
Expand All @@ -111,7 +152,24 @@ setup:
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test sparse vector search with pruning config":
"Test sparse vector search with vector dimensions":
- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
ml.tokens:
vector_dimensions:
the: 1.0
comforter: 1.0
smells: 1.0
bad: 1.0
- match: { hits.total.value: 5 }
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test sparse vector search with a model ID and pruning config":
- do:
search:
index: index-with-sparse-vector
Expand All @@ -127,6 +185,26 @@ setup:
- match: { hits.total.value: 4 }
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test sparse vector search with vector dimensions and pruning config":
- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
ml.tokens:
vector_dimensions:
the: 1.0
comforter: 1.0
smells: 1.0
bad: 1.0
pruning_config:
tokens_freq_ratio_threshold: 4
tokens_weight_threshold: 0.4
- match: { hits.total.value: 5 }
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test named, boosted sparse vector search with pruning config":
- do:
Expand Down Expand Up @@ -165,7 +243,7 @@ setup:
- match: { hits.hits.0._score: 300.0 }

---
"Test sparse vector search with default pruning config":
"Test sparse vector search with a model ID and default pruning config":
- do:
search:
index: index-with-sparse-vector
Expand All @@ -180,7 +258,25 @@ setup:
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test sparse vector search with weighted tokens rescoring only pruned tokens":
"Test sparse vector search with vector dimensions and default pruning config":
- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
ml.tokens:
vector_dimensions:
the: 1.0
comforter: 1.0
smells: 1.0
bad: 1.0
pruning_config: {}
- match: { hits.total.value: 4 }
- match: { hits.hits.0._source.source_text: "the octopus comforter smells" }

---
"Test sparse vector search with model ID rescoring only pruned tokens":
- do:
search:
index: index-with-sparse-vector
Expand All @@ -196,6 +292,26 @@ setup:
only_score_pruned_tokens: true
- match: { hits.total.value: 0 }

---
"Test sparse vector search with vector dimensions rescoring only pruned tokens":
- do:
search:
index: index-with-sparse-vector
body:
query:
sparse_vector:
ml.tokens:
vector_dimensions:
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 that sparse vector queries return error for invalid queried field type":
- do:
Expand Down

0 comments on commit db44c87

Please sign in to comment.