From d6f01f612090361b2712ca5af3e58ccc01e2cf8c Mon Sep 17 00:00:00 2001 From: akonczak Date: Sun, 10 Nov 2013 11:18:44 -0800 Subject: [PATCH] Created Custom ObjectMapper (markdown) --- Custom-ObjectMapper.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Custom-ObjectMapper.md diff --git a/Custom-ObjectMapper.md b/Custom-ObjectMapper.md new file mode 100644 index 0000000..23d493b --- /dev/null +++ b/Custom-ObjectMapper.md @@ -0,0 +1,36 @@ +How to use custom ObjectMapper? + +1. Create new Class and implement Interface EntityMapper +``` +public class CustomEntityMapper implements EntityMapper { + + public CustomEntityMapper(){ + //custom configuration/implementation (e.g. FasterXML/jackson) + } + + @Override + public String mapToString(Object object) throws IOException { + //mapping Object to String + return null; + } + + @Override + public T mapToObject(String source, Class clazz) throws IOException { + //mapping String to Object + return null; + } +} +``` +2. Define new bean and inject it into ElasticsearchTemplate +``` + + + + + + +``` +3. Done + +Default implementation for EntityMapper used in project can be found here https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/core/DefaultEntityMapper.java \ No newline at end of file