From 3fb28de7ad47c1bc410a88cf3f66c9ff6fd20067 Mon Sep 17 00:00:00 2001 From: Artur Konczak Date: Sun, 17 Nov 2013 22:04:04 +0000 Subject: [PATCH] DATAES-34 #17 - documentation for custom result mapper --- README.md | 61 +++++++++++++++++++ .../core/CustomResultMapper.java | 4 +- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 59f4f6165..a5f5edfd4 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,67 @@ Indexing multiple Document(bulk index) using Repository repository.save(sampleEntities); ``` +### Adding custom behaviors to ResultMapper - CustomResultMapper + +Define new class implementing ResultMapper + +```java +public class CustomResultMapper implements ResultsMapper{ + + private EntityMapper entityMapper; + + public CustomResultMapper(EntityMapper entityMapper) { + this.entityMapper = entityMapper; + } + + @Override + public EntityMapper getEntityMapper() { + return entityMapper; + } + + @Override + public T mapResult(GetResponse response, Class clazz) { + return null; //Your implementation + } + + @Override + public FacetedPage mapResults(SearchResponse response, Class clazz, Pageable pageable) { + return null; //Your implementation + } +} + +``` + +Inject your custom implementation to template + + +```xml + + + + + + + + + + + + + + + + + + + +``` + ### Geo indexing and request You can make request using geo_distance filter. This can be done using GeoPoint object. diff --git a/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java b/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java index e2676fa9a..dc531b577 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/CustomResultMapper.java @@ -5,9 +5,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.springframework.data.domain.Pageable; /** - * User: dead - * Date: 11/11/13 - * Time: 17:37 + * @author Artur Konczak */ public class CustomResultMapper implements ResultsMapper{