@Override
 public void validate(ParseContext context) throws MapperParsingException {
   String routing = context.sourceToParse().routing();
   if (path != null && routing != null) {
     // we have a path, check if we can validate we have the same routing value as the one in the
     // doc...
     String value = null;
     Fieldable field = context.doc().getFieldable(path);
     if (field != null) {
       value = field.stringValue();
       if (value == null) {
         // maybe its a numeric field...
         if (field instanceof NumberFieldMapper.CustomNumericField) {
           value = ((NumberFieldMapper.CustomNumericField) field).numericAsString();
         }
       }
     }
     if (value == null) {
       value = context.ignoredValue(path);
     }
     if (value == null) {
       // maybe its a numeric field
     }
     if (!routing.equals(value)) {
       throw new MapperParsingException(
           "External routing ["
               + routing
               + "] and document path routing ["
               + value
               + "] mismatch");
     }
   }
 }
  @Override
  protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
    ValueAndBoost valueAndBoost = parseCreateFieldForString(context, nullValue, boost);
    if (valueAndBoost.value() == null) {
      return;
    }
    if (ignoreAbove > 0 && valueAndBoost.value().length() > ignoreAbove) {
      return;
    }
    if (context.includeInAll(includeInAll, this)) {
      context.allEntries().addText(names.fullName(), valueAndBoost.value(), valueAndBoost.boost());
    }

    if (fieldType.indexOptions() != IndexOptions.NONE || fieldType.stored()) {
      Field field = new Field(names.indexName(), valueAndBoost.value(), fieldType);
      field.setBoost(valueAndBoost.boost());
      fields.add(field);
    }
    if (hasDocValues()) {
      fields.add(
          new SortedSetDocValuesField(names.indexName(), new BytesRef(valueAndBoost.value())));
    }
    if (fields.isEmpty()) {
      context.ignoredValue(names.indexName(), valueAndBoost.value());
    }
  }
 @Override
 protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
   if (context.sourceToParse().routing() != null) {
     String routing = context.sourceToParse().routing();
     if (routing != null) {
       if (fieldType.indexOptions() == IndexOptions.NONE && !fieldType.stored()) {
         context.ignoredValue(fieldType.names().indexName(), routing);
         return;
       }
       fields.add(new Field(fieldType.names().indexName(), routing, fieldType));
     }
   }
 }
 @Override
 protected Field parseCreateField(ParseContext context) throws IOException {
   if (context.sourceToParse().routing() != null) {
     String routing = context.sourceToParse().routing();
     if (routing != null) {
       if (!indexed() && !stored()) {
         context.ignoredValue(names.indexName(), routing);
         return null;
       }
       return new Field(names.indexName(), routing, store, index);
     }
   }
   return null;
 }
 @Override
 protected Field parseCreateField(ParseContext context) throws IOException {
   String value = nullValue;
   float boost = this.boost;
   if (context.externalValueSet()) {
     value = (String) context.externalValue();
   } else {
     XContentParser parser = context.parser();
     if (parser.currentToken() == XContentParser.Token.VALUE_NULL) {
       value = nullValue;
     } else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
       XContentParser.Token token;
       String currentFieldName = null;
       while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
         if (token == XContentParser.Token.FIELD_NAME) {
           currentFieldName = parser.currentName();
         } else {
           if ("value".equals(currentFieldName) || "_value".equals(currentFieldName)) {
             value = parser.textOrNull();
           } else if ("boost".equals(currentFieldName) || "_boost".equals(currentFieldName)) {
             boost = parser.floatValue();
           } else {
             throw new ElasticSearchIllegalArgumentException(
                 "unknown property [" + currentFieldName + "]");
           }
         }
       }
     } else {
       value = parser.textOrNull();
     }
   }
   if (value == null) {
     return null;
   }
   if (ignoreAbove > 0 && value.length() > ignoreAbove) {
     return null;
   }
   if (context.includeInAll(includeInAll, this)) {
     context.allEntries().addText(names.fullName(), value, boost);
   }
   if (!fieldType().indexed() && !fieldType().stored()) {
     context.ignoredValue(names.indexName(), value);
     return null;
   }
   Field field = new StringField(names.indexName(), value, fieldType);
   field.setBoost(boost);
   return field;
 }