本文整理汇总了Java中org.elasticsearch.index.mapper.object.ObjectMapper类的典型用法代码示例。如果您正苦于以下问题:Java ObjectMapper类的具体用法?Java ObjectMapper怎么用?Java ObjectMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectMapper类属于org.elasticsearch.index.mapper.object包,在下文中一共展示了ObjectMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
public Mapper create(String name, ObjectMapper parentMapper, ParseContext context) {
BuilderContext builderContext = new BuilderContext(context.indexSettings(), context.path());
try {
Mapper.Builder<?, ?> innerBuilder = detectInnerMapper(context, name, context.parser());
if (innerBuilder == null) {
return null;
}
Mapper mapper = innerBuilder.build(builderContext);
mapper = DocumentParser.parseAndMergeUpdate(mapper, context);
MappedFieldType mappedFieldType = newArrayFieldType(innerBuilder);
String fullName = context.path().fullPathAsText(name);
mappedFieldType.setNames(new MappedFieldType.Names(fullName));
return new ArrayMapper(
name,
mappedFieldType,
mappedFieldType.clone(),
context.indexSettings(),
MultiFields.empty(),
null,
mapper);
} catch (IOException e) {
throw Throwables.propagate(e);
}
}
示例2: parse
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
Object inner = node.remove(INNER_TYPE);
if (inner == null) {
throw new MapperParsingException("property [inner] missing");
}
if (!(inner instanceof Map)) {
throw new MapperParsingException("property [inner] must be a map");
}
@SuppressWarnings("unchecked")
Map<String, Object> innerNode = (Map<String, Object>) inner;
String typeName = (String)innerNode.get("type");
if (typeName == null && innerNode.containsKey("properties")) {
typeName = ObjectMapper.CONTENT_TYPE;
} else if (CONTENT_TYPE.equalsIgnoreCase(typeName)) {
throw new MapperParsingException("nested arrays are not supported");
}
Mapper.TypeParser innerTypeParser = parserContext.typeParser(typeName);
Mapper.Builder innerBuilder = innerTypeParser.parse(name, innerNode, parserContext);
return new Builder(name, innerBuilder);
}
示例3: doMerge
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
@Override
protected void doMerge(Mapper mergeWith, boolean updateAllTypes) {
if (mergeWith instanceof ArrayMapper) {
innerMapper = innerMapper.merge(((ArrayMapper) mergeWith).innerMapper, updateAllTypes);
} else {
innerMapper = innerMapper.merge(mergeWith, updateAllTypes);
}
MappedFieldType newArrayFieldType = null;
if (innerMapper instanceof ObjectMapper) {
newArrayFieldType = new ObjectArrayFieldType();
}
if (innerMapper instanceof FieldMapper) {
newArrayFieldType = new ArrayFieldType(((FieldMapper) innerMapper).fieldType());
}
newArrayFieldType.setNames(this.fieldType.names());
this.fieldType = newArrayFieldType;
}
示例4: registerBuiltInMappers
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
private void registerBuiltInMappers() {
registerMapper(ByteFieldMapper.CONTENT_TYPE, new ByteFieldMapper.TypeParser());
registerMapper(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser());
registerMapper(IntegerFieldMapper.CONTENT_TYPE, new IntegerFieldMapper.TypeParser());
registerMapper(LongFieldMapper.CONTENT_TYPE, new LongFieldMapper.TypeParser());
registerMapper(FloatFieldMapper.CONTENT_TYPE, new FloatFieldMapper.TypeParser());
registerMapper(DoubleFieldMapper.CONTENT_TYPE, new DoubleFieldMapper.TypeParser());
registerMapper(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser());
registerMapper(BinaryFieldMapper.CONTENT_TYPE, new BinaryFieldMapper.TypeParser());
registerMapper(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser());
registerMapper(IpFieldMapper.CONTENT_TYPE, new IpFieldMapper.TypeParser());
registerMapper(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser());
registerMapper(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser());
registerMapper(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser());
registerMapper(ObjectMapper.NESTED_CONTENT_TYPE, new ObjectMapper.TypeParser());
registerMapper(TypeParsers.MULTI_FIELD_CONTENT_TYPE, TypeParsers.multiFieldConverterTypeParser);
registerMapper(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser());
registerMapper(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser());
if (ShapesAvailability.JTS_AVAILABLE) {
registerMapper(GeoShapeFieldMapper.CONTENT_TYPE, new GeoShapeFieldMapper.TypeParser());
}
}
示例5: createInternal
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
@Override
public Aggregator createInternal(AggregationContext context, Aggregator parent, boolean collectsFromSingleBucket,
List<PipelineAggregator> pipelineAggregators, Map<String, Object> metaData) throws IOException {
// Early validation
NestedAggregator closestNestedAggregator = findClosestNestedAggregator(parent);
if (closestNestedAggregator == null) {
throw new SearchParseException(context.searchContext(), "Reverse nested aggregation [" + name
+ "] can only be used inside a [nested] aggregation", null);
}
final ObjectMapper objectMapper;
if (path != null) {
objectMapper = context.searchContext().getObjectMapper(path);
if (objectMapper == null) {
return new Unmapped(name, context, parent, pipelineAggregators, metaData);
}
if (!objectMapper.nested().isNested()) {
throw new AggregationExecutionException("[reverse_nested] nested path [" + path + "] is not nested");
}
} else {
objectMapper = null;
}
return new ReverseNestedAggregator(name, factories, objectMapper, context, parent, pipelineAggregators, metaData);
}
示例6: parseNested
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
private InnerHitsContext.NestedInnerHits parseNested(XContentParser parser, QueryParseContext parseContext, SearchContext searchContext, String nestedPath) throws Exception {
ObjectMapper objectMapper = searchContext.getObjectMapper(nestedPath);
if (objectMapper == null) {
throw new IllegalArgumentException("path [" + nestedPath +"] doesn't exist");
}
if (objectMapper.nested().isNested() == false) {
throw new IllegalArgumentException("path [" + nestedPath +"] isn't nested");
}
ObjectMapper parentObjectMapper = parseContext.nestedScope().nextLevel(objectMapper);
ParseResult parseResult = parseSubSearchContext(searchContext, parseContext, parser);
parseContext.nestedScope().previousLevel();
return new InnerHitsContext.NestedInnerHits(parseResult.context(), parseResult.query(), parseResult.childInnerHits(), parentObjectMapper, objectMapper);
}
示例7: setPathLevel
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
private void setPathLevel() {
ObjectMapper objectMapper = parseContext.nestedScope().getObjectMapper();
if (objectMapper == null) {
parentFilter = parseContext.bitsetFilter(Queries.newNonNestedFilter());
} else {
parentFilter = parseContext.bitsetFilter(objectMapper.nestedTypeFilter());
}
childFilter = nestedObjectMapper.nestedTypeFilter();
parentObjectMapper = parseContext.nestedScope().nextLevel(nestedObjectMapper);
}
示例8: checkObjectsCompatibility
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
private void checkObjectsCompatibility(String type, Collection<ObjectMapper> objectMappers, Collection<FieldMapper> fieldMappers, boolean updateAllTypes) {
assert Thread.holdsLock(this);
for (ObjectMapper newObjectMapper : objectMappers) {
ObjectMapper existingObjectMapper = fullPathObjectMappers.get(newObjectMapper.fullPath());
if (existingObjectMapper != null) {
// simulate a merge and ignore the result, we are just interested
// in exceptions here
existingObjectMapper.merge(newObjectMapper, updateAllTypes);
}
}
}
示例9: checkNestedFieldsLimit
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
private void checkNestedFieldsLimit(Map<String, ObjectMapper> fullPathObjectMappers) {
long allowedNestedFields = indexSettingsService.getSettings().getAsLong(INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING, 50L);
long actualNestedFields = 0;
for (ObjectMapper objectMapper : fullPathObjectMappers.values()) {
if (objectMapper.nested().isNested()) {
actualNestedFields++;
}
}
if (allowedNestedFields >= 0 && actualNestedFields > allowedNestedFields) {
throw new IllegalArgumentException("Limit of nested fields [" + allowedNestedFields + "] in index [" + index().name() + "] has been exceeded");
}
}
示例10: resolveClosestNestedObjectMapper
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
/**
* Resolves the closest inherited {@link ObjectMapper} that is nested.
*/
public ObjectMapper resolveClosestNestedObjectMapper(String fieldName) {
int indexOf = fieldName.lastIndexOf('.');
if (indexOf == -1) {
return null;
} else {
do {
String objectPath = fieldName.substring(0, indexOf);
ObjectMapper objectMapper = fullPathObjectMappers.get(objectPath);
if (objectMapper == null) {
indexOf = objectPath.lastIndexOf('.');
continue;
}
if (objectMapper.nested().isNested()) {
return objectMapper;
}
indexOf = objectPath.lastIndexOf('.');
} while (indexOf != -1);
}
return null;
}
示例11: findNestedObjectMapper
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
/**
* Returns the best nested {@link ObjectMapper} instances that is in the scope of the specified nested docId.
*/
public ObjectMapper findNestedObjectMapper(int nestedDocId, SearchContext sc, LeafReaderContext context) throws IOException {
ObjectMapper nestedObjectMapper = null;
for (ObjectMapper objectMapper : objectMappers().values()) {
if (!objectMapper.nested().isNested()) {
continue;
}
Query filter = objectMapper.nestedTypeFilter();
if (filter == null) {
continue;
}
// We can pass down 'null' as acceptedDocs, because nestedDocId is a doc to be fetched and
// therefor is guaranteed to be a live doc.
final Weight nestedWeight = filter.createWeight(sc.searcher(), false);
Scorer scorer = nestedWeight.scorer(context);
if (scorer == null) {
continue;
}
if (scorer.iterator().advance(nestedDocId) == nestedDocId) {
if (nestedObjectMapper == null) {
nestedObjectMapper = objectMapper;
} else {
if (nestedObjectMapper.fullPath().length() < objectMapper.fullPath().length()) {
nestedObjectMapper = objectMapper;
}
}
}
}
return nestedObjectMapper;
}
示例12: parseNonDynamicArray
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
private static ObjectMapper parseNonDynamicArray(ParseContext context, ObjectMapper mapper, String lastFieldName, String arrayFieldName) throws IOException {
XContentParser parser = context.parser();
XContentParser.Token token;
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
if (token == XContentParser.Token.START_OBJECT) {
return parseObject(context, mapper, lastFieldName);
} else if (token == XContentParser.Token.START_ARRAY) {
return parseArray(context, mapper, lastFieldName);
} else if (token == XContentParser.Token.FIELD_NAME) {
lastFieldName = parser.currentName();
} else if (token == XContentParser.Token.VALUE_NULL) {
parseNullValue(context, mapper, lastFieldName);
} else if (token == null) {
throw new MapperParsingException("object mapping for [" + mapper.name() + "] with array for [" + arrayFieldName + "] tried to parse as array, but got EOF, is there a mismatch in types for the same field?");
} else {
return parseValue(context, mapper, lastFieldName, token);
}
}
return null;
}
示例13: configureRootObjectBuilder
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
@Override
protected void configureRootObjectBuilder(RootObjectMapper.Builder builder) {
builder
.add(new DateFieldMapper.Builder("dateTime"))
.add(new FloatFieldMapper.Builder("temperature"))
.add(new FloatFieldMapper.Builder("windSpeed"))
.add(new FloatFieldMapper.Builder("stationPressure"))
.add(new StringFieldMapper.Builder("skyCondition"))
.add(new ObjectMapper.Builder("station")
.add(new StringFieldMapper.Builder("wban"))
.add(new StringFieldMapper.Builder("name"))
.add(new StringFieldMapper.Builder("state"))
.add(new StringFieldMapper.Builder("location"))
.add(new GeoPointFieldMapper.Builder("coordinates")
.enableLatLon(true)
.enableGeoHash(false))
.nested(ObjectMapper.Nested.newNested(true, false)));
}
示例14: registerBuiltInMappers
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
private static Map<String, Mapper.TypeParser> registerBuiltInMappers() {
Map<String, Mapper.TypeParser> mapperParsers = new LinkedHashMap<>();
mapperParsers.put(ByteFieldMapper.CONTENT_TYPE, new ByteFieldMapper.TypeParser());
mapperParsers.put(ShortFieldMapper.CONTENT_TYPE, new ShortFieldMapper.TypeParser());
mapperParsers.put(IntegerFieldMapper.CONTENT_TYPE, new IntegerFieldMapper.TypeParser());
mapperParsers.put(LongFieldMapper.CONTENT_TYPE, new LongFieldMapper.TypeParser());
mapperParsers.put(FloatFieldMapper.CONTENT_TYPE, new FloatFieldMapper.TypeParser());
mapperParsers.put(DoubleFieldMapper.CONTENT_TYPE, new DoubleFieldMapper.TypeParser());
mapperParsers.put(BooleanFieldMapper.CONTENT_TYPE, new BooleanFieldMapper.TypeParser());
mapperParsers.put(BinaryFieldMapper.CONTENT_TYPE, new BinaryFieldMapper.TypeParser());
mapperParsers.put(DateFieldMapper.CONTENT_TYPE, new DateFieldMapper.TypeParser());
mapperParsers.put(IpFieldMapper.CONTENT_TYPE, new IpFieldMapper.TypeParser());
mapperParsers.put(StringFieldMapper.CONTENT_TYPE, new StringFieldMapper.TypeParser());
mapperParsers.put(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser());
mapperParsers.put(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser());
mapperParsers.put(ObjectMapper.NESTED_CONTENT_TYPE, new ObjectMapper.TypeParser());
mapperParsers.put(TypeParsers.MULTI_FIELD_CONTENT_TYPE, TypeParsers.multiFieldConverterTypeParser);
mapperParsers.put(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser());
mapperParsers.put(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser());
return mapperParsers;
}
示例15: configure
import org.elasticsearch.index.mapper.object.ObjectMapper; //导入依赖的package包/类
@Override
protected void configure(RootObjectMapper.Builder builder) {
builder
.add(new DateFieldMapper.Builder("dateTime"))
.add(new FloatFieldMapper.Builder("temperature"))
.add(new FloatFieldMapper.Builder("windSpeed"))
.add(new FloatFieldMapper.Builder("stationPressure"))
.add(new StringFieldMapper.Builder("skyCondition"))
.add(new ObjectMapper.Builder("station")
.add(new StringFieldMapper.Builder("wban"))
.add(new StringFieldMapper.Builder("name"))
.add(new StringFieldMapper.Builder("state"))
.add(new StringFieldMapper.Builder("location"))
.add(new GeoPointFieldMapper.Builder("coordinates")
.enableLatLon(true)
.enableGeoHash(false))
.nested(ObjectMapper.Nested.newNested(true, false)));
}