Tests: Add type-unrestricted version of field mapper getter to SearchContext.
This fixes an NPE when using TestSearchContext in SignificanceHeuristicTests.
This commit is contained in:
parent
ecc8b702d3
commit
1ebc95ee28
|
@ -663,6 +663,11 @@ public class PercolateContext extends SearchContext {
|
||||||
return mapperService().smartNameFieldMapper(name, types);
|
return mapperService().smartNameFieldMapper(name, types);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FieldMapper smartNameFieldMapperFromAnyType(String name) {
|
||||||
|
return mapperService().smartNameFieldMapper(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
|
@ -152,7 +152,7 @@ public class ValuesSourceParser<VS extends ValuesSource> {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
FieldMapper<?> mapper = context.mapperService().smartNameFieldMapper(input.field);
|
FieldMapper<?> mapper = context.smartNameFieldMapperFromAnyType(input.field);
|
||||||
if (mapper == null) {
|
if (mapper == null) {
|
||||||
Class<VS> valuesSourceType = valueType != null ? (Class<VS>) valueType.getValuesSourceType() : this.valuesSourceType;
|
Class<VS> valuesSourceType = valueType != null ? (Class<VS>) valueType.getValuesSourceType() : this.valuesSourceType;
|
||||||
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType);
|
ValuesSourceConfig<VS> config = new ValuesSourceConfig<>(valuesSourceType);
|
||||||
|
|
|
@ -671,18 +671,27 @@ public class DefaultSearchContext extends SearchContext {
|
||||||
return scanContext;
|
return scanContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MapperService.SmartNameFieldMappers smartFieldMappers(String name) {
|
public MapperService.SmartNameFieldMappers smartFieldMappers(String name) {
|
||||||
return mapperService().smartName(name, request.types());
|
return mapperService().smartName(name, request.types());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FieldMappers smartNameFieldMappers(String name) {
|
public FieldMappers smartNameFieldMappers(String name) {
|
||||||
return mapperService().smartNameFieldMappers(name, request.types());
|
return mapperService().smartNameFieldMappers(name, request.types());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FieldMapper smartNameFieldMapper(String name) {
|
public FieldMapper smartNameFieldMapper(String name) {
|
||||||
return mapperService().smartNameFieldMapper(name, request.types());
|
return mapperService().smartNameFieldMapper(name, request.types());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FieldMapper smartNameFieldMapperFromAnyType(String name) {
|
||||||
|
return mapperService().smartNameFieldMapper(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
||||||
return mapperService().smartNameObjectMapper(name, request.types());
|
return mapperService().smartNameObjectMapper(name, request.types());
|
||||||
}
|
}
|
||||||
|
|
|
@ -548,6 +548,11 @@ public abstract class FilteredSearchContext extends SearchContext {
|
||||||
return in.smartNameFieldMapper(name);
|
return in.smartNameFieldMapper(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FieldMapper smartNameFieldMapperFromAnyType(String name) {
|
||||||
|
return in.smartNameFieldMapperFromAnyType(name);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
||||||
return in.smartNameObjectMapper(name);
|
return in.smartNameObjectMapper(name);
|
||||||
|
|
|
@ -349,6 +349,11 @@ public abstract class SearchContext implements Releasable {
|
||||||
|
|
||||||
public abstract FieldMapper smartNameFieldMapper(String name);
|
public abstract FieldMapper smartNameFieldMapper(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks up the given field, but does not restrict to fields in the types set on this context.
|
||||||
|
*/
|
||||||
|
public abstract FieldMapper smartNameFieldMapperFromAnyType(String name);
|
||||||
|
|
||||||
public abstract MapperService.SmartNameObjectMapper smartNameObjectMapper(String name);
|
public abstract MapperService.SmartNameObjectMapper smartNameObjectMapper(String name);
|
||||||
|
|
||||||
public abstract Counter timeEstimateCounter();
|
public abstract Counter timeEstimateCounter();
|
||||||
|
|
|
@ -570,9 +570,20 @@ public class TestSearchContext extends SearchContext {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FieldMapper<?> smartNameFieldMapperFromAnyType(String name) {
|
||||||
|
if (mapperService() != null) {
|
||||||
|
return mapperService().smartNameFieldMapper(name);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
public MapperService.SmartNameObjectMapper smartNameObjectMapper(String name) {
|
||||||
return mapperService().smartNameObjectMapper(name, types);
|
if (mapperService() != null) {
|
||||||
|
return mapperService().smartNameObjectMapper(name, types);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue