Skip to content

Commit a83ecbc

Browse files
committed
wip
1 parent 637807c commit a83ecbc

File tree

2 files changed

+7
-14
lines changed

2 files changed

+7
-14
lines changed

server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,12 @@ public Builder builder(BlockFactory factory, int expectedCount) {
10871087
* using whatever
10881088
*/
10891089
private BlockSourceReader.LeafIteratorLookup blockReaderDisiLookup(BlockLoaderContext blContext) {
1090+
if (isSyntheticSource && syntheticSourceDelegate != null) {
1091+
// Since we are using synthetic source and a delegate, we can't use this field
1092+
// to determine if the delegate has values in the document (f.e. handling of `null` is different
1093+
// between text and keyword).
1094+
return BlockSourceReader.lookupMatchingAll();
1095+
}
10901096
if (isIndexed()) {
10911097
if (getTextSearchInfo().hasNorms()) {
10921098
return BlockSourceReader.lookupFromNorms(name());

server/src/test/java/org/elasticsearch/index/mapper/blockloader/TextFieldBlockLoaderTests.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,8 @@ public static Object expectedValue(Map<String, Object> fieldMapping, Object valu
6262
if (params.syntheticSource() && testContext.forceFallbackSyntheticSource() == false && usingSyntheticSourceDelegate) {
6363
var nullValue = (String) keywordMultiFieldMapping.get("null_value");
6464

65-
// Due to how TextFieldMapper#blockReaderDisiLookup works this is complicated.
66-
// If we are using lookupMatchingAll() then we'll see all docs, generate synthetic source using syntheticSourceDelegate,
67-
// parse it and see null_value inside.
68-
// But if we are using lookupFromNorms() we will skip the document (since the text field itself does not exist).
69-
// Same goes for lookupFromFieldNames().
70-
boolean textFieldIndexed = (boolean) fieldMapping.getOrDefault("index", true);
71-
7265
if (value == null) {
73-
if (textFieldIndexed == false && nullValue != null && nullValue.length() <= (int) ignoreAbove) {
66+
if (nullValue != null && nullValue.length() <= (int) ignoreAbove) {
7467
return new BytesRef(nullValue);
7568
}
7669

@@ -82,12 +75,6 @@ public static Object expectedValue(Map<String, Object> fieldMapping, Object valu
8275
}
8376

8477
var values = (List<String>) value;
85-
86-
// See note above about TextFieldMapper#blockReaderDisiLookup.
87-
if (textFieldIndexed && values.stream().allMatch(Objects::isNull)) {
88-
return null;
89-
}
90-
9178
var indexed = values.stream()
9279
.map(s -> s == null ? nullValue : s)
9380
.filter(Objects::nonNull)

0 commit comments

Comments
 (0)