private static void parseObjectOrField(ParseContext context, Mapper mapper) throws IOException { if (mapper instanceof ObjectMapper) { parseObjectOrNested(context, (ObjectMapper) mapper); } else if (mapper instanceof FieldMapper) { FieldMapper fieldMapper = (FieldMapper) mapper; fieldMapper.parse(context); parseCopyFields(context, fieldMapper.copyTo().copyToFields()); } else if (mapper instanceof FieldAliasMapper) { throw new IllegalArgumentException("Cannot write to a field alias [" + mapper.name() + "]."); } else { throw new IllegalStateException("The provided mapper [" + mapper.name() + "] has an unrecognized type [" + mapper.getClass().getSimpleName() + "]."); } }
/** Creates an copy of the current field with given field name and boost */ private static void parseCopy(String field, ParseContext context) throws IOException { Mapper mapper = context.docMapper().mappers().getMapper(field); if (mapper != null) { if (mapper instanceof FieldMapper) { ((FieldMapper) mapper).parse(context); } else if (mapper instanceof FieldAliasMapper) { throw new IllegalArgumentException("Cannot copy to a field alias [" + mapper.name() + "]."); } else { throw new IllegalStateException("The provided mapper [" + mapper.name() + "] has an unrecognized type [" + mapper.getClass().getSimpleName() + "]."); } } else { // The path of the dest field might be completely different from the current one so we need to reset it context = context.overridePath(new ContentPath(0)); final String[] paths = splitAndValidatePath(field); final String fieldName = paths[paths.length-1]; Tuple<Integer, ObjectMapper> parentMapperTuple = getDynamicParentMapper(context, paths, null); ObjectMapper objectMapper = parentMapperTuple.v2(); parseDynamicValue(context, objectMapper, fieldName, context.parser().currentToken()); for (int i = 0; i < parentMapperTuple.v1(); i++) { context.path().remove(); } } }
public void parse(FieldMapper mainField, ParseContext context) throws IOException { // TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part // of the mappings if (mappers.isEmpty()) { return; } context = context.createMultiFieldContext(); context.path().add(mainField.simpleName()); for (ObjectCursor<FieldMapper> cursor : mappers.values()) { cursor.value.parse(context); } context.path().remove(); }
private void addGeoHashField(ParseContext context, String geoHash) throws IOException { LegacyGeoPointFieldType ft = (LegacyGeoPointFieldType)fieldType; int len = Math.min(ft.geoHashPrecision(), geoHash.length()); int min = ft.isGeoHashPrefixEnabled() ? 1 : len; for (int i = len; i >= min; i--) { // side effect of this call is adding the field geoHashMapper.parse(context.createExternalValueContext(geoHash.substring(0, i))); } }
/** Creates an copy of the current field with given field name and boost */ private static void parseCopy(final String field, final ParseContext context) throws IOException { Mapper mapper = context.docMapper().mappers().getMapper(field); if (mapper != null) { if (mapper instanceof FieldMapper) { ((FieldMapper) mapper).parse(context); } else if (mapper instanceof FieldAliasMapper) { throw new IllegalArgumentException("Cannot copy to a field alias [" + mapper.name() + "]."); } else { throw new IllegalStateException("The provided mapper [" + mapper.name() + "] has an unrecognized type [" + mapper.getClass().getSimpleName() + "]."); } } }
private static void parseObjectOrField(ParseContext context, Mapper mapper) throws IOException { if (mapper instanceof ObjectMapper) { parseObjectOrNested(context, (ObjectMapper) mapper); } else if (mapper instanceof FieldMapper) { FieldMapper fieldMapper = (FieldMapper) mapper; fieldMapper.parse(context); parseCopyFields(context, fieldMapper.copyTo().copyToFields()); } else if (mapper instanceof FieldAliasMapper) { throw new IllegalArgumentException("Cannot write to a field alias [" + mapper.name() + "]."); } else { throw new IllegalStateException("The provided mapper [" + mapper.name() + "] has an unrecognized type [" + mapper.getClass().getSimpleName() + "]."); } }
private static void parseObjectOrField(ParseContext context, Mapper mapper) throws IOException { if (mapper instanceof ObjectMapper) { parseObjectOrNested(context, (ObjectMapper) mapper); } else if (mapper instanceof FieldMapper) { FieldMapper fieldMapper = (FieldMapper) mapper; Mapper update = fieldMapper.parse(context); if (update != null) { context.addDynamicMapper(update); } parseCopyFields(context, fieldMapper.copyTo().copyToFields()); } else if (mapper instanceof FieldAliasMapper) { throw new IllegalArgumentException("Cannot write to a field alias [" + mapper.name() + "]."); } else { throw new IllegalStateException("The provided mapper [" + mapper.name() + "] has an unrecognized type [" + mapper.getClass().getSimpleName() + "]."); } }
private static Mapper parseObjectOrField(ParseContext context, Mapper mapper) throws IOException { if (mapper instanceof ObjectMapper) { return parseObject(context, (ObjectMapper) mapper, false); } else { FieldMapper fieldMapper = (FieldMapper)mapper; Mapper update = fieldMapper.parse(context); if (fieldMapper.copyTo() != null) { parseCopyFields(context, fieldMapper, fieldMapper.copyTo().copyToFields()); } return update; } }
private static void parseObjectOrField(ParseContext context, Mapper mapper) throws IOException { if (mapper instanceof ObjectMapper) { parseObjectOrNested(context, (ObjectMapper) mapper, false); } else { FieldMapper fieldMapper = (FieldMapper)mapper; Mapper update = fieldMapper.parse(context); if (update != null) { context.addDynamicMapper(update); } if (fieldMapper.copyTo() != null) { parseCopyFields(context, fieldMapper.copyTo().copyToFields()); } } }
public void parse(ParseContext context, GeoPoint point, String geoHash) throws IOException { if (legacyFieldType().isGeoHashEnabled()) { if (geoHash == null) { geoHash = GeoHashUtils.stringEncode(point.lon(), point.lat()); } addGeoHashField(context, geoHash); } if (legacyFieldType().isLatLonEnabled()) { latMapper.parse(context.createExternalValueContext(point.lat())); lonMapper.parse(context.createExternalValueContext(point.lon())); } multiFields.parse(this, context.createExternalValueContext(point)); }
public void parse(FieldMapper mainField, ParseContext context) throws IOException { // TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part of the mappings if (mappers.isEmpty()) { return; } context = context.createMultiFieldContext(); context.path().add(mainField.simpleName()); for (ObjectCursor<FieldMapper> cursor : mappers.values()) { cursor.value.parse(context); } context.path().remove(); }
public void parse(FieldMapper mainField, ParseContext context) throws IOException { // TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part of the mappings if (mappers.isEmpty()) { return; } context = context.createMultiFieldContext(); context.path().add(mainField.simpleName()); for (ObjectCursor<FieldMapper> cursor : mappers.values()) { cursor.value.parse(context); } context.path().remove(); }
public void parse(FieldMapper mainField, ParseContext context) throws IOException { // TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part of the mappings if (mappers.isEmpty()) { return; } context = context.createMultiFieldContext(); context.path().add(mainField.simpleName()); for (ObjectCursor<FieldMapper> cursor : mappers.values()) { cursor.value.parse(context); } context.path().remove(); }
/** Creates an copy of the current field with given field name and boost */ private static void parseCopy(String field, ParseContext context) throws IOException { Mapper mapper = context.docMapper().mappers().getMapper(field); if (mapper != null) { if (mapper instanceof FieldMapper) { ((FieldMapper) mapper).parse(context); } else if (mapper instanceof FieldAliasMapper) { throw new IllegalArgumentException("Cannot copy to a field alias [" + mapper.name() + "]."); } else { throw new IllegalStateException("The provided mapper [" + mapper.name() + "] has an unrecognized type [" + mapper.getClass().getSimpleName() + "]."); } } else { // The path of the dest field might be completely different from the current one so we need to reset it context = context.overridePath(new ContentPath(0)); final String[] paths = splitAndValidatePath(field); final String fieldName = paths[paths.length-1]; Tuple<Integer, ObjectMapper> parentMapperTuple = getDynamicParentMapper(context, paths, null); ObjectMapper objectMapper = parentMapperTuple.v2(); parseDynamicValue(context, objectMapper, fieldName, context.parser().currentToken()); for (int i = 0; i < parentMapperTuple.v1(); i++) { context.path().remove(); } } }
/** Creates an copy of the current field with given field name and boost */ private static void parseCopy(String field, ParseContext context) throws IOException { Mapper mapper = context.docMapper().mappers().getMapper(field); if (mapper != null) { if (mapper instanceof FieldMapper) { ((FieldMapper) mapper).parse(context); } else if (mapper instanceof FieldAliasMapper) { throw new IllegalArgumentException("Cannot copy to a field alias [" + mapper.name() + "]."); } else { throw new IllegalStateException("The provided mapper [" + mapper.name() + "] has an unrecognized type [" + mapper.getClass().getSimpleName() + "]."); } } else { // The path of the dest field might be completely different from the current one so we need to reset it context = context.overridePath(new ContentPath(0)); final String[] paths = splitAndValidatePath(field); final String fieldName = paths[paths.length-1]; Tuple<Integer, ObjectMapper> parentMapperTuple = getDynamicParentMapper(context, paths, null); ObjectMapper objectMapper = parentMapperTuple.v2(); parseDynamicValue(context, objectMapper, fieldName, context.parser().currentToken()); for (int i = 0; i < parentMapperTuple.v1(); i++) { context.path().remove(); } } }
contentMapper.parse(context); languageMapper.parse(context); } catch(Throwable t) { logger.debug("Cannot detect language: [{}]", t.getMessage()); try { context = context.createExternalValueContext(name); nameMapper.parse(context); } catch(MapperParsingException e){ if (!ignoreErrors) throw e; try { context = context.createExternalValueContext(metadata.get(Metadata.DATE)); dateMapper.parse(context); } catch(MapperParsingException e){ if (!ignoreErrors) throw e; try { context = context.createExternalValueContext(metadata.get(Metadata.TITLE)); titleMapper.parse(context); } catch(MapperParsingException e){ if (!ignoreErrors) throw e; try { context = context.createExternalValueContext(metadata.get(Metadata.AUTHOR)); authorMapper.parse(context); } catch(MapperParsingException e){ if (!ignoreErrors) throw e;
public void parse(FieldMapper mainField, ParseContext context) throws IOException { // TODO: multi fields are really just copy fields, we just need to expose "sub fields" or something that can be part of the mappings if (mappers.isEmpty()) { return; } context = context.createMultiFieldContext(); ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); context.path().add(mainField.simpleName()); for (ObjectCursor<FieldMapper> cursor : mappers.values()) { cursor.value.parse(context); } context.path().remove(); context.path().pathType(origPathType); }
/** Creates an copy of the current field with given field name and boost */ private static void parseCopy(String field, ParseContext context) throws IOException { FieldMapper fieldMapper = context.docMapper().mappers().getMapper(field); if (fieldMapper != null) { fieldMapper.parse(context); } else { // The path of the dest field might be completely different from the current one so we need to reset it context = context.overridePath(new ContentPath(0)); final String[] paths = splitAndValidatePath(field); final String fieldName = paths[paths.length-1]; Tuple<Integer, ObjectMapper> parentMapperTuple = getDynamicParentMapper(context, paths, null); ObjectMapper mapper = parentMapperTuple.v2(); parseDynamicValue(context, mapper, fieldName, context.parser().currentToken()); for (int i = 0; i < parentMapperTuple.v1(); i++) { context.path().remove(); } } }
FieldMapper fieldMapper = context.docMapper().mappers().getMapper(field); if (fieldMapper != null) { fieldMapper.parse(context); } else {