Skip to content

Commit

Permalink
Merge branch '8.x' into 8-x-backport-114951
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Oct 23, 2024
2 parents 9ec8a9c + 30485d4 commit 592cdbb
Show file tree
Hide file tree
Showing 27 changed files with 554 additions and 521 deletions.
3 changes: 2 additions & 1 deletion docs/reference/security/limitations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ including the following queries:
* A search request cannot be profiled if document level security is enabled.
* The <<search-terms-enum,terms enum API>> does not return terms if document
level security is enabled.
* The <<query-dsl-multi-match-query, `multi_match`>> query does not support specifying fields using wildcards.

NOTE: While document-level security prevents users from viewing restricted documents,
it's still possible to write search requests that return aggregate information about the
entire index. A user whose access is restricted to specific documents in an index could
still learn about field names and terms that only exist in inaccessible
documents, and count how many inaccessible documents contain a given term.
documents, and count how many inaccessible documents contain a given term.

[discrete]
[[alias-limitations]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
SourceValueFetcher fetcher = SourceValueFetcher.toString(blContext.sourcePaths(name()));
// MatchOnlyText never has norms, so we have to use the field names field
BlockSourceReader.LeafIteratorLookup lookup = BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name());
var sourceMode = blContext.indexSettings().getIndexMappingSourceMode();
return new BlockSourceReader.BytesRefsBlockLoader(fetcher, lookup, sourceMode);
return new BlockSourceReader.BytesRefsBlockLoader(fetcher, lookup);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
BlockSourceReader.LeafIteratorLookup lookup = isStored() || isIndexed()
? BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
: BlockSourceReader.lookupMatchingAll();
var sourceMode = blContext.indexSettings().getIndexMappingSourceMode();
return new BlockSourceReader.DoublesBlockLoader(valueFetcher, lookup, sourceMode);
return new BlockSourceReader.DoublesBlockLoader(valueFetcher, lookup);
}

@Override
Expand Down
15 changes: 0 additions & 15 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ tests:
- class: org.elasticsearch.packaging.test.WindowsServiceTests
method: test80JavaOptsInEnvVar
issue: https://github.com/elastic/elasticsearch/issues/113219
- class: org.elasticsearch.xpack.esql.expression.function.aggregate.AvgTests
method: "testFold {TestCase=<double> #2}"
issue: https://github.com/elastic/elasticsearch/issues/113225
- class: org.elasticsearch.packaging.test.WindowsServiceTests
method: test81JavaOptsInJvmOptions
issue: https://github.com/elastic/elasticsearch/issues/113313
Expand Down Expand Up @@ -395,18 +392,6 @@ tests:
- class: org.elasticsearch.xpack.enrich.EnrichIT
method: testDeleteExistingPipeline
issue: https://github.com/elastic/elasticsearch/issues/114775
- class: org.elasticsearch.index.mapper.TextFieldMapperTests
method: testBlockLoaderFromRowStrideReaderWithSyntheticSource
issue: https://github.com/elastic/elasticsearch/issues/115066
- class: org.elasticsearch.index.mapper.TextFieldMapperTests
method: testBlockLoaderFromColumnReaderWithSyntheticSource
issue: https://github.com/elastic/elasticsearch/issues/115073
- class: org.elasticsearch.index.mapper.annotatedtext.AnnotatedTextFieldMapperTests
method: testBlockLoaderFromColumnReaderWithSyntheticSource
issue: https://github.com/elastic/elasticsearch/issues/115074
- class: org.elasticsearch.index.mapper.annotatedtext.AnnotatedTextFieldMapperTests
method: testBlockLoaderFromRowStrideReaderWithSyntheticSource
issue: https://github.com/elastic/elasticsearch/issues/115076
- class: org.elasticsearch.xpack.enrich.EnrichIT
method: testEnrichSpecialTypes
issue: https://github.com/elastic/elasticsearch/issues/114773
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
protected BlockLoader blockLoaderFromSource(BlockLoaderContext blContext) {
ValueFetcher fetcher = valueFetcher(blContext.sourcePaths(name()), nullValue, GeometryFormatterFactory.WKB);
// TODO consider optimization using BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
var sourceMode = blContext.indexSettings().getIndexMappingSourceMode();
return new BlockSourceReader.GeometriesBlockLoader(fetcher, BlockSourceReader.lookupMatchingAll(), sourceMode);
return new BlockSourceReader.GeometriesBlockLoader(fetcher, BlockSourceReader.lookupMatchingAll());
}

protected abstract Object nullValueAsSource(T nullValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,13 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
* Loads values from {@code _source}. This whole process is very slow and cast-tastic,
* so it doesn't really try to avoid megamorphic invocations. It's just going to be
* slow.
*/
public abstract class BlockSourceReader implements BlockLoader.RowStrideReader {

// _ignored_source is needed when source mode is synthetic.
static final StoredFieldsSpec NEEDS_SOURCE_AND_IGNORED_SOURCE = new StoredFieldsSpec(
true,
false,
Set.of(IgnoredSourceFieldMapper.NAME)
);

private final ValueFetcher fetcher;
private final List<Object> ignoredValues = new ArrayList<>();
private final DocIdSetIterator iter;
Expand Down Expand Up @@ -100,12 +91,10 @@ public interface LeafIteratorLookup {
private abstract static class SourceBlockLoader implements BlockLoader {
protected final ValueFetcher fetcher;
private final LeafIteratorLookup lookup;
private final SourceFieldMapper.Mode sourceMode;

private SourceBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
private SourceBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup) {
this.fetcher = fetcher;
this.lookup = lookup;
this.sourceMode = sourceMode;
}

@Override
Expand All @@ -115,7 +104,7 @@ public final ColumnAtATimeReader columnAtATimeReader(LeafReaderContext context)

@Override
public final StoredFieldsSpec rowStrideStoredFieldSpec() {
return sourceMode == SourceFieldMapper.Mode.SYNTHETIC ? NEEDS_SOURCE_AND_IGNORED_SOURCE : StoredFieldsSpec.NEEDS_SOURCE;
return StoredFieldsSpec.NEEDS_SOURCE;
}

@Override
Expand Down Expand Up @@ -151,8 +140,8 @@ public final String toString() {
* Load {@code boolean}s from {@code _source}.
*/
public static class BooleansBlockLoader extends SourceBlockLoader {
public BooleansBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
super(fetcher, lookup, sourceMode);
public BooleansBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup) {
super(fetcher, lookup);
}

@Override
Expand Down Expand Up @@ -191,8 +180,8 @@ public String toString() {
* Load {@link BytesRef}s from {@code _source}.
*/
public static class BytesRefsBlockLoader extends SourceBlockLoader {
public BytesRefsBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
super(fetcher, lookup, sourceMode);
public BytesRefsBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup) {
super(fetcher, lookup);
}

@Override
Expand All @@ -202,7 +191,7 @@ public final Builder builder(BlockFactory factory, int expectedCount) {

@Override
protected RowStrideReader rowStrideReader(LeafReaderContext context, DocIdSetIterator iter) throws IOException {
return new BytesRefs(fetcher, iter, null);
return new BytesRefs(fetcher, iter);
}

@Override
Expand All @@ -212,8 +201,8 @@ protected String name() {
}

public static class GeometriesBlockLoader extends SourceBlockLoader {
public GeometriesBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
super(fetcher, lookup, sourceMode);
public GeometriesBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup) {
super(fetcher, lookup);
}

@Override
Expand All @@ -223,7 +212,7 @@ public final Builder builder(BlockFactory factory, int expectedCount) {

@Override
protected RowStrideReader rowStrideReader(LeafReaderContext context, DocIdSetIterator iter) {
return new Geometries(fetcher, iter, null);
return new Geometries(fetcher, iter);
}

@Override
Expand All @@ -235,7 +224,7 @@ protected String name() {
private static class BytesRefs extends BlockSourceReader {
private final BytesRef scratch = new BytesRef();

BytesRefs(ValueFetcher fetcher, DocIdSetIterator iter, SourceFieldMapper.Mode sourceMode) {
BytesRefs(ValueFetcher fetcher, DocIdSetIterator iter) {
super(fetcher, iter);
}

Expand All @@ -252,7 +241,7 @@ public String toString() {

private static class Geometries extends BlockSourceReader {

Geometries(ValueFetcher fetcher, DocIdSetIterator iter, SourceFieldMapper.Mode sourceMode) {
Geometries(ValueFetcher fetcher, DocIdSetIterator iter) {
super(fetcher, iter);
}

Expand All @@ -275,8 +264,8 @@ public String toString() {
* Load {@code double}s from {@code _source}.
*/
public static class DoublesBlockLoader extends SourceBlockLoader {
public DoublesBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
super(fetcher, lookup, sourceMode);
public DoublesBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup) {
super(fetcher, lookup);
}

@Override
Expand Down Expand Up @@ -315,8 +304,8 @@ public String toString() {
* Load {@code int}s from {@code _source}.
*/
public static class IntsBlockLoader extends SourceBlockLoader {
public IntsBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
super(fetcher, lookup, sourceMode);
public IntsBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup) {
super(fetcher, lookup);
}

@Override
Expand Down Expand Up @@ -355,8 +344,8 @@ public String toString() {
* Load {@code long}s from {@code _source}.
*/
public static class LongsBlockLoader extends SourceBlockLoader {
public LongsBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup, SourceFieldMapper.Mode sourceMode) {
super(fetcher, lookup, sourceMode);
public LongsBlockLoader(ValueFetcher fetcher, LeafIteratorLookup lookup) {
super(fetcher, lookup);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
BlockSourceReader.LeafIteratorLookup lookup = isIndexed() || isStored()
? BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
: BlockSourceReader.lookupMatchingAll();
return new BlockSourceReader.BooleansBlockLoader(fetcher, lookup, blContext.indexSettings().getIndexMappingSourceMode());
return new BlockSourceReader.BooleansBlockLoader(fetcher, lookup);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
BlockSourceReader.LeafIteratorLookup lookup = isStored() || isIndexed()
? BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
: BlockSourceReader.lookupMatchingAll();
var sourceMode = blContext.indexSettings().getIndexMappingSourceMode();
return new BlockSourceReader.LongsBlockLoader(sourceValueFetcher(blContext.sourcePaths(name())), lookup, sourceMode);
return new BlockSourceReader.LongsBlockLoader(sourceValueFetcher(blContext.sourcePaths(name())), lookup);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
return new BlockStoredFieldsReader.BytesFromBytesRefsBlockLoader(name());
}
SourceValueFetcher fetcher = sourceValueFetcher(blContext.sourcePaths(name()));
var sourceMode = blContext.indexSettings().getIndexMappingSourceMode();
return new BlockSourceReader.BytesRefsBlockLoader(fetcher, sourceBlockLoaderLookup(blContext), sourceMode);
return new BlockSourceReader.BytesRefsBlockLoader(fetcher, sourceBlockLoaderLookup(blContext));
}

private BlockSourceReader.LeafIteratorLookup sourceBlockLoaderLookup(BlockLoaderContext blContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,8 @@ BlockLoader blockLoaderFromDocValues(String fieldName) {
}

@Override
BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
) {
return new BlockSourceReader.DoublesBlockLoader(sourceValueFetcher, lookup, sourceMode);
BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup) {
return new BlockSourceReader.DoublesBlockLoader(sourceValueFetcher, lookup);
}
},
FLOAT("float", NumericType.FLOAT) {
Expand Down Expand Up @@ -649,12 +645,8 @@ BlockLoader blockLoaderFromDocValues(String fieldName) {
}

@Override
BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
) {
return new BlockSourceReader.DoublesBlockLoader(sourceValueFetcher, lookup, sourceMode);
BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup) {
return new BlockSourceReader.DoublesBlockLoader(sourceValueFetcher, lookup);
}
},
DOUBLE("double", NumericType.DOUBLE) {
Expand Down Expand Up @@ -803,12 +795,8 @@ BlockLoader blockLoaderFromDocValues(String fieldName) {
}

@Override
BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
) {
return new BlockSourceReader.DoublesBlockLoader(sourceValueFetcher, lookup, sourceMode);
BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup) {
return new BlockSourceReader.DoublesBlockLoader(sourceValueFetcher, lookup);
}
},
BYTE("byte", NumericType.BYTE) {
Expand Down Expand Up @@ -920,12 +908,8 @@ BlockLoader blockLoaderFromDocValues(String fieldName) {
}

@Override
BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
) {
return new BlockSourceReader.IntsBlockLoader(sourceValueFetcher, lookup, sourceMode);
BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup) {
return new BlockSourceReader.IntsBlockLoader(sourceValueFetcher, lookup);
}

private boolean isOutOfRange(Object value) {
Expand Down Expand Up @@ -1037,12 +1021,8 @@ BlockLoader blockLoaderFromDocValues(String fieldName) {
}

@Override
BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
) {
return new BlockSourceReader.IntsBlockLoader(sourceValueFetcher, lookup, sourceMode);
BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup) {
return new BlockSourceReader.IntsBlockLoader(sourceValueFetcher, lookup);
}

private boolean isOutOfRange(Object value) {
Expand Down Expand Up @@ -1228,12 +1208,8 @@ BlockLoader blockLoaderFromDocValues(String fieldName) {
}

@Override
BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
) {
return new BlockSourceReader.IntsBlockLoader(sourceValueFetcher, lookup, sourceMode);
BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup) {
return new BlockSourceReader.IntsBlockLoader(sourceValueFetcher, lookup);
}
},
LONG("long", NumericType.LONG) {
Expand Down Expand Up @@ -1379,12 +1355,8 @@ BlockLoader blockLoaderFromDocValues(String fieldName) {
}

@Override
BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
) {
return new BlockSourceReader.LongsBlockLoader(sourceValueFetcher, lookup, sourceMode);
BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup) {
return new BlockSourceReader.LongsBlockLoader(sourceValueFetcher, lookup);
}

private boolean isOutOfRange(Object value) {
Expand Down Expand Up @@ -1662,11 +1634,7 @@ protected void writeValue(XContentBuilder b, long value) throws IOException {

abstract BlockLoader blockLoaderFromDocValues(String fieldName);

abstract BlockLoader blockLoaderFromSource(
SourceValueFetcher sourceValueFetcher,
BlockSourceReader.LeafIteratorLookup lookup,
SourceFieldMapper.Mode sourceMode
);
abstract BlockLoader blockLoaderFromSource(SourceValueFetcher sourceValueFetcher, BlockSourceReader.LeafIteratorLookup lookup);
}

public static class NumberFieldType extends SimpleMappedFieldType {
Expand Down Expand Up @@ -1805,8 +1773,7 @@ public BlockLoader blockLoader(BlockLoaderContext blContext) {
BlockSourceReader.LeafIteratorLookup lookup = isStored() || isIndexed()
? BlockSourceReader.lookupFromFieldNames(blContext.fieldNames(), name())
: BlockSourceReader.lookupMatchingAll();
var sourceMode = blContext.indexSettings().getIndexMappingSourceMode();
return type.blockLoaderFromSource(sourceValueFetcher(blContext.sourcePaths(name())), lookup, sourceMode);
return type.blockLoaderFromSource(sourceValueFetcher(blContext.sourcePaths(name())), lookup);
}

@Override
Expand Down
Loading

0 comments on commit 592cdbb

Please sign in to comment.