|
@@ -80,7 +80,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
MapperBuilderContext context = MapperBuilderContext.ROOT;
|
|
|
final MappedFieldType stringMapper = new KeywordFieldMapper.Builder("string", Version.CURRENT).build(context).fieldType();
|
|
|
ifdService.clear();
|
|
|
- IndexFieldData<?> fd = ifdService.getForField(stringMapper, "test", () -> { throw new UnsupportedOperationException(); });
|
|
|
+ IndexFieldData<?> fd = ifdService.getForField(stringMapper, FieldDataContext.noRuntimeFields("test"));
|
|
|
assertTrue(fd instanceof SortedSetOrdinalsIndexFieldData);
|
|
|
|
|
|
for (MappedFieldType mapper : Arrays.asList(
|
|
@@ -90,7 +90,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
new NumberFieldMapper.Builder("long", LONG, ScriptCompiler.NONE, false, true, Version.CURRENT).build(context).fieldType()
|
|
|
)) {
|
|
|
ifdService.clear();
|
|
|
- fd = ifdService.getForField(mapper, "test", () -> { throw new UnsupportedOperationException(); });
|
|
|
+ fd = ifdService.getForField(mapper, FieldDataContext.noRuntimeFields("test"));
|
|
|
assertTrue(fd instanceof SortedNumericIndexFieldData);
|
|
|
}
|
|
|
|
|
@@ -103,7 +103,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
Version.CURRENT
|
|
|
).build(context).fieldType();
|
|
|
ifdService.clear();
|
|
|
- fd = ifdService.getForField(floatMapper, "test", () -> { throw new UnsupportedOperationException(); });
|
|
|
+ fd = ifdService.getForField(floatMapper, FieldDataContext.noRuntimeFields("test"));
|
|
|
assertTrue(fd instanceof SortedDoublesIndexFieldData);
|
|
|
|
|
|
final MappedFieldType doubleMapper = new NumberFieldMapper.Builder(
|
|
@@ -115,7 +115,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
Version.CURRENT
|
|
|
).build(context).fieldType();
|
|
|
ifdService.clear();
|
|
|
- fd = ifdService.getForField(doubleMapper, "test", () -> { throw new UnsupportedOperationException(); });
|
|
|
+ fd = ifdService.getForField(doubleMapper, FieldDataContext.noRuntimeFields("test"));
|
|
|
assertTrue(fd instanceof SortedDoublesIndexFieldData);
|
|
|
}
|
|
|
|
|
@@ -129,14 +129,14 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
);
|
|
|
final SetOnce<Supplier<SearchLookup>> searchLookupSetOnce = new SetOnce<>();
|
|
|
MappedFieldType ft = mock(MappedFieldType.class);
|
|
|
- when(ft.fielddataBuilder(ArgumentMatchers.any(), ArgumentMatchers.any())).thenAnswer(invocationOnMock -> {
|
|
|
+ when(ft.fielddataBuilder(ArgumentMatchers.any())).thenAnswer(invocationOnMock -> {
|
|
|
@SuppressWarnings("unchecked")
|
|
|
- Supplier<SearchLookup> searchLookup = (Supplier<SearchLookup>) invocationOnMock.getArguments()[1];
|
|
|
- searchLookupSetOnce.set(searchLookup);
|
|
|
+ FieldDataContext fdc = (FieldDataContext) invocationOnMock.getArguments()[0];
|
|
|
+ searchLookupSetOnce.set(fdc.lookupSupplier());
|
|
|
return (IndexFieldData.Builder) (cache, breakerService) -> null;
|
|
|
});
|
|
|
SearchLookup searchLookup = new SearchLookup(null, null);
|
|
|
- ifdService.getForField(ft, "qualified", () -> searchLookup);
|
|
|
+ ifdService.getForField(ft, new FieldDataContext("qualified", () -> searchLookup));
|
|
|
assertSame(searchLookup, searchLookupSetOnce.get().get());
|
|
|
}
|
|
|
|
|
@@ -176,8 +176,8 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
onRemovalCalled.incrementAndGet();
|
|
|
}
|
|
|
});
|
|
|
- IndexFieldData<?> ifd1 = ifdService.getForField(mapper1, "test", () -> { throw new UnsupportedOperationException(); });
|
|
|
- IndexFieldData<?> ifd2 = ifdService.getForField(mapper2, "test", () -> { throw new UnsupportedOperationException(); });
|
|
|
+ IndexFieldData<?> ifd1 = ifdService.getForField(mapper1, FieldDataContext.noRuntimeFields("test"));
|
|
|
+ IndexFieldData<?> ifd2 = ifdService.getForField(mapper2, FieldDataContext.noRuntimeFields("test"));
|
|
|
LeafReaderContext leafReaderContext = reader.getContext().leaves().get(0);
|
|
|
LeafFieldData loadField1 = ifd1.load(leafReaderContext);
|
|
|
LeafFieldData loadField2 = ifd2.load(leafReaderContext);
|
|
@@ -251,7 +251,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
onRemovalCalled.incrementAndGet();
|
|
|
}
|
|
|
});
|
|
|
- IndexFieldData<?> ifd = ifdService.getForField(mapper1, "test", () -> { throw new UnsupportedOperationException(); });
|
|
|
+ IndexFieldData<?> ifd = ifdService.getForField(mapper1, FieldDataContext.noRuntimeFields("test"));
|
|
|
LeafReaderContext leafReaderContext = reader.getContext().leaves().get(0);
|
|
|
LeafFieldData load = ifd.load(leafReaderContext);
|
|
|
assertEquals(1, onCacheCalled.get());
|
|
@@ -313,11 +313,11 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
|
|
null
|
|
|
);
|
|
|
if (ft.hasDocValues()) {
|
|
|
- ifds.getForField(ft, "test", () -> { throw new UnsupportedOperationException(); }); // no exception
|
|
|
+ ifds.getForField(ft, FieldDataContext.noRuntimeFields("test")); // no exception
|
|
|
} else {
|
|
|
IllegalArgumentException e = expectThrows(
|
|
|
IllegalArgumentException.class,
|
|
|
- () -> ifds.getForField(ft, "test", () -> { throw new UnsupportedOperationException(); })
|
|
|
+ () -> ifds.getForField(ft, FieldDataContext.noRuntimeFields("test"))
|
|
|
);
|
|
|
assertThat(e.getMessage(), containsString("doc values"));
|
|
|
}
|