Skip to content

Commit

Permalink
Copy text_expansion query to a new sparse_vector. No major changes ma…
Browse files Browse the repository at this point in the history
…de yet.
  • Loading branch information
kderusso committed Mar 29, 2024
1 parent 3d53707 commit 0854dc8
Show file tree
Hide file tree
Showing 9 changed files with 1,874 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ static TransportVersion def(int id) {
public static final TransportVersion SEARCH_NODE_LOAD_AUTOSCALING = def(8_617_00_0);
public static final TransportVersion ESQL_ES_SOURCE_OPTIONS = def(8_618_00_0);
public static final TransportVersion ADD_PERSISTENT_TASK_EXCEPTIONS = def(8_619_00_0);
public static final TransportVersion ADD_SPARSE_VECTOR_QUERY = def(8_620_00_0);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ teardown:
index: index-with-sparse-vector
body:
query:
text_expansion:
sparse_vector:
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.12.99"
reason: "pruning introduced in 8.13.0"
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
text_expansion:
sparse_vector:
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.12.99"
reason: "pruning introduced in 8.13.0"
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"
- do:
search:
index: index-with-sparse-vector
body:
query:
text_expansion:
sparse_vector:
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:
text_expansion:
sparse_vector:
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.12.99"
reason: "pruning introduced in 8.13.0"
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
text_expansion:
sparse_vector:
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.12.99"
reason: "pruning introduced in 8.13.0"
version: " - 8.13.99"
reason: "sparse_vector query introduced in 8.14.0"

- do:
search:
index: index-with-sparse-vector
body:
query:
text_expansion:
sparse_vector:
ml.tokens:
model_id: text_expansion_model
model_text: "octopus comforter smells"
Expand All @@ -243,82 +243,3 @@ 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 }
Loading

0 comments on commit 0854dc8

Please sign in to comment.