예제 #1
0
  public void testSerializeDefaults() throws Exception {
    String mapping =
        XContentFactory.jsonBuilder()
            .startObject()
            .startObject("type")
            .startObject("properties")
            .startObject("field")
            .field("type", "ip")
            .endObject()
            .endObject()
            .endObject()
            .endObject()
            .string();

    DocumentMapper docMapper = parser.parse("type", new CompressedXContent(mapping));
    IpFieldMapper mapper = (IpFieldMapper) docMapper.root().getMapper("field");
    XContentBuilder builder = XContentFactory.jsonBuilder().startObject();
    mapper.doXContentBody(builder, true, ToXContent.EMPTY_PARAMS);
    String got = builder.endObject().string();

    // it would be nice to check the entire serialized default mapper, but there are
    // a whole lot of bogus settings right now it picks up from calling super.doXContentBody...
    assertTrue(got, got.contains("\"null_value\":null"));
    assertTrue(got, got.contains("\"ignore_malformed\":false"));
    assertTrue(got, got.contains("\"include_in_all\":false"));
  }
예제 #2
0
 @Override
 public IpFieldMapper build(BuilderContext context) {
   fieldType.setOmitNorms(fieldType.omitNorms() && boost == 1.0f);
   IpFieldMapper fieldMapper =
       new IpFieldMapper(
           buildNames(context),
           fieldType.numericPrecisionStep(),
           boost,
           fieldType,
           docValues,
           nullValue,
           ignoreMalformed(context),
           coerce(context),
           postingsProvider,
           docValuesProvider,
           similarity,
           normsLoading,
           fieldDataSettings,
           context.indexSettings(),
           multiFieldsBuilder.build(this, context),
           copyTo);
   fieldMapper.includeInAll(includeInAll);
   return fieldMapper;
 }