Jackson Date field serialization


#1

I'm using elasticsearch in order to create my index.

Everything is fasty.

I chose jackson in order to generate elasticsearch index documents

So, I've created this serializer:

public class DigitalInputSerializer extends JsonSerializer<DigitalInput> {

    @Override
    public void serialize(DigitalInput value, JsonGenerator gen,
        SerializerProvider serializers) throws IOException,
        JsonProcessingException {

        gen.writeStartObject();
        gen.writeNumberField("timestamp", value.getTimestamp().getTime());   <<<<<<<<<<<<<<<
        gen.writeStringField("matter", value.getMatter());
        gen.writeStringField("comment", value.getComment());
        gen.writeStringField("channel_id", value.getChannelId());
        gen.writeEndObject();

    }

}

I've had a surprise, when I looked for a writeDateField!!! It isn't there!

Then I chose to index this field using a long field, however I'm losing
the date type indexable features that elasticsearch provides.

Could you help me, please?

Thanks for all.


(system) #2