Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jimczi committed Dec 4, 2024
1 parent 167d686 commit f170bdd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
14 changes: 9 additions & 5 deletions docs/reference/mapping/types/sparse-vector.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ The following parameters are accepted by `sparse_vector` fields:

[horizontal]

<<mapping-store,`store`>>::

Whether the field value should be stored and retrievable separately from
the <<mapping-source-field,`_source`>> field. Accepts `true` or `false`
(default).
<<mapping-store,store>>::

Indicates whether the field value should be stored and retrievable independently of the <<mapping-source-field,_source>> field.
Accepted values: true or false (default).
The field's data is stored using term vectors, a disk-efficient structure compared to the original JSON input.
The input map can be retrieved during a search request via the <<search-fields-param,`fields` parameter>>.
To benefit from reduced disk usage, you must either:
* Exclude the field from <<source-filtering, _source>>.
* Use <<synthetic-source,synthetic `_source`>>.

[[index-multi-value-sparse-vectors]]
==== Multi-value sparse vectors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class MapperFeatures implements FeatureSpecification {
// Used to avoid noise in mixed cluster and rest compatibility tests. Must not be backported to 8.x branch.
// This label gets added to tests with such failures before merging with main, then removed when backported to 8.x.
public static final NodeFeature BWC_WORKAROUND_9_0 = new NodeFeature("mapper.bwc_workaround_9_0");
public static final NodeFeature SPARSE_VECTOR_STORE_SUPPORT = new NodeFeature("mapper.sparse_vector.store_support");

@Override
public Set<NodeFeature> getFeatures() {
Expand Down Expand Up @@ -76,8 +75,7 @@ public Set<NodeFeature> getTestFeatures() {
MapperService.LOGSDB_DEFAULT_IGNORE_DYNAMIC_BEYOND_LIMIT,
DocumentParser.FIX_PARSING_SUBOBJECTS_FALSE_DYNAMIC_FALSE,
CONSTANT_KEYWORD_SYNTHETIC_SOURCE_WRITE_FIX,
META_FETCH_FIELDS_ERROR_CODE_CHANGED,
SPARSE_VECTOR_STORE_SUPPORT
META_FETCH_FIELDS_ERROR_CODE_CHANGED
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.IndexVersions;
import org.elasticsearch.index.analysis.NamedAnalyzer;
Expand Down Expand Up @@ -58,6 +59,8 @@ public class SparseVectorFieldMapper extends FieldMapper {

public static final String CONTENT_TYPE = "sparse_vector";

public static final NodeFeature SPARSE_VECTOR_STORE_SUPPORT = new NodeFeature("mapper.sparse_vector.store_support");

static final String ERROR_MESSAGE_7X = "[sparse_vector] field type in old 7.x indices is allowed to "
+ "contain [sparse_vector] fields, but they cannot be indexed or searched.";
static final String ERROR_MESSAGE_8X = "The [sparse_vector] field type is not supported on indices created on versions 8.0 to 8.10.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.elasticsearch.features.FeatureSpecification;
import org.elasticsearch.features.NodeFeature;
import org.elasticsearch.index.mapper.vectors.SparseVectorFieldMapper;
import org.elasticsearch.license.License;
import org.elasticsearch.xpack.core.datatiers.NodesDataTiersUsageTransportAction;

Expand All @@ -30,4 +31,9 @@ public Set<NodeFeature> getFeatures() {
LOGSDB_TELMETRY_STATS
);
}

@Override
public Set<NodeFeature> getTestFeatures() {
return Set.of(SparseVectorFieldMapper.SPARSE_VECTOR_STORE_SUPPORT);
}
}

0 comments on commit f170bdd

Please sign in to comment.