forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring back sparse_vector mapping (elastic#98996)
Adds back `sparse_vector` field type, as a copy of `rank_features`. The main goal is to have the `sparse_vector` field type available so we can switch ELSER queries to use the new type.
- Loading branch information
1 parent
3f55232
commit 2562894
Showing
7 changed files
with
468 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 98996 | ||
summary: Reintroduce `sparse_vector` mapping | ||
area: Mapping | ||
type: enhancement | ||
issues: [] |
143 changes: 143 additions & 0 deletions
143
...pi-spec/src/yamlRestTest/resources/rest-api-spec/test/search.vectors/90_sparse_vector.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
--- | ||
"Indexing and searching sparse vectors": | ||
|
||
- skip: | ||
version: " - 8.10.99" | ||
reason: "sparse_vector field type reintroduced in 8.11" | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
text: | ||
type: text | ||
ml.tokens: | ||
type: sparse_vector | ||
|
||
- match: { acknowledged: true } | ||
|
||
- do: | ||
index: | ||
index: test | ||
id: "1" | ||
body: | ||
text: "running is good for you" | ||
ml: | ||
tokens: | ||
running: 2.4097164 | ||
good: 2.170997 | ||
run: 2.052153 | ||
race: 1.4575411 | ||
for: 1.1908325 | ||
runner: 1.1803857 | ||
exercise: 1.1652642 | ||
you: 0.9654308 | ||
training: 0.94999343 | ||
sports: 0.93650943 | ||
fitness: 0.83129317 | ||
best: 0.820365 | ||
bad: 0.7385934 | ||
health: 0.7098149 | ||
marathon: 0.61555296 | ||
gym: 0.5652374 | ||
|
||
- match: { result: "created" } | ||
|
||
- do: | ||
index: | ||
index: test | ||
id: "2" | ||
body: | ||
text: "walking is a healthy exercise" | ||
ml: | ||
tokens: | ||
walking: 2.4797723 | ||
exercise: 2.074234 | ||
healthy: 1.971596 | ||
walk: 1.6458614 | ||
health: 1.5291847 | ||
walker: 1.4736869 | ||
activity: 1.0793462 | ||
good: 1.0597849 | ||
fitness: 0.91855437 | ||
training: 0.86342937 | ||
movement: 0.7657065 | ||
normal: 0.6694081 | ||
foot: 0.5892523 | ||
physical: 0.4926789 | ||
|
||
- match: { result: "created" } | ||
|
||
- do: | ||
indices.refresh: { } | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
bool: | ||
should: | ||
- term: | ||
ml.tokens: | ||
value: "walk" | ||
boost: 1.9790847 | ||
- term: | ||
ml.tokens: | ||
value: "walking" | ||
boost: 1.7092685 | ||
- term: | ||
ml.tokens: | ||
value: "exercise" | ||
boost: 0.84076905 | ||
|
||
- match: { hits.total.value: 2 } | ||
- match: { hits.hits.0._id: "2" } | ||
- match: { hits.hits.1._id: "1" } | ||
|
||
--- | ||
"Sparse vector in 7.x": | ||
- skip: | ||
features: allowed_warnings | ||
version: "8.0.0 - " | ||
reason: "sparse_vector field type supported in 7.x" | ||
- do: | ||
allowed_warnings: | ||
- "The [sparse_vector] field type is deprecated and will be removed in 8.0." | ||
- "[sparse_vector] field type in old 7.x indices is allowed to contain [sparse_vector] fields, but they cannot be indexed or searched." | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
text: | ||
type: text | ||
ml.tokens: | ||
type: sparse_vector | ||
|
||
- match: { acknowledged: true } | ||
|
||
--- | ||
"Sparse vector in 8.x": | ||
- skip: | ||
version: " - 7.99.99, 8.11.0 - " | ||
reason: "sparse_vector field type not supported in 8.x until 8.11.0" | ||
- do: | ||
catch: /The \[sparse_vector\] field type is no longer supported/ | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
text: | ||
type: text | ||
ml.tokens: | ||
type: sparse_vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.