Loading src/main/java/es/redmic/elasticsearchlib/common/repository/RBaseESRepository.java +6 −20 Original line number Diff line number Diff line Loading @@ -308,14 +308,10 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte protected abstract JavaType getSourceType(Class<?> wrapperClass); protected GetResponse getRequest(String id) { return getRequest(id, null, null); return getRequest(id, null); } protected GetResponse getRequest(String id, String parentId) { return getRequest(id, parentId, null); } protected GetResponse getRequest(String id, String parentId, String grandparentId) { LOGGER.debug("FindById en " + getIndex() + " " + getType() + " con id " + id); Loading @@ -324,10 +320,7 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte GetRequest getRequest = new GetRequest(getIndex()[i], getType(), id.toString()); if (parentId != null) { getRequest.parent(parentId); } if (grandparentId != null) { getRequest.routing(grandparentId); getRequest.routing(parentId); } GetResponse response; Loading @@ -335,7 +328,7 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte response = ESProvider.getClient().get(getRequest, RequestOptions.DEFAULT); } catch (IOException e) { e.printStackTrace(); throw new ItemNotFoundException("id", id + " en el servicio " + getType()); throw new ItemNotFoundException("id", id + " en el servicio " + getIndex()[i] + " - " + getType()); } if (response != null && response.isExists()) { Loading @@ -343,7 +336,7 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte } } throw new ItemNotFoundException("id", id + " en el servicio " + getType()); throw new ItemNotFoundException("id", id + " en el servicio " + getIndex()[0] + " - " + getType()); } public List<String> suggest(TQueryDTO queryDTO) { Loading Loading @@ -412,11 +405,6 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte protected MultiGetResponse multigetRequest(MgetDTO dto, String parentId) { return multigetRequest(dto, parentId, null); } protected MultiGetResponse multigetRequest(MgetDTO dto, String parentId, String grandParentId) { LOGGER.debug("Mget en " + getIndex() + " " + getType() + " con fields " + dto.getFields() + " e ids " + dto.getIds()); Loading @@ -438,11 +426,9 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte Item item = new Item(getIndex()[i], getType(), dto.getIds().get(k)); if (parentId != null) { item.parent(parentId); } if (grandParentId != null) { item.routing(grandParentId); item.routing(parentId); } item.fetchSourceContext(fetchSourceContext); request.add(item); } Loading src/main/java/es/redmic/elasticsearchlib/common/utils/ElasticPersistenceUtils.java +6 −15 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { .setRefreshPolicy(RefreshPolicy.IMMEDIATE); if (parentId != null) { request.parent(parentId); request.routing(parentId); } // @formatter:on Loading Loading @@ -105,7 +105,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { .setRefreshPolicy(RefreshPolicy.IMMEDIATE); if (parentId != null) { updateRequest.parent(parentId); updateRequest.routing(parentId); } // @formatter:on Loading Loading @@ -139,7 +139,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { // @formatter:on if (parentId != null) { updateRequest.parent(parentId); updateRequest.routing(parentId); } try { Loading @@ -162,7 +162,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { DeleteRequest deleteRequest = new DeleteRequest(index, type, id).setRefreshPolicy(RefreshPolicy.IMMEDIATE); if (parentId != null) { deleteRequest.parent(parentId); deleteRequest.routing(parentId); } try { Loading @@ -181,18 +181,12 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { public List<UpdateRequest> getUpdateRequest(String[] index, String[] type, String id, Map<String, Object> fields) { return getUpdateRequest(index, type, id, fields, null, null); return getUpdateRequest(index, type, id, fields, null); } public List<UpdateRequest> getUpdateRequest(String[] index, String[] type, String id, Map<String, Object> fields, String parentId) { return getUpdateRequest(index, type, id, fields, parentId, null); } public List<UpdateRequest> getUpdateRequest(String[] index, String[] type, String id, Map<String, Object> fields, String parentId, String grandParentId) { List<UpdateRequest> result = new ArrayList<UpdateRequest>(); for (int i = 0; i < index.length; i++) { Loading @@ -203,10 +197,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { updateRequest.id(id); updateRequest.fetchSource(true); if (parentId != null) updateRequest.parent(grandParentId); if (grandParentId != null) updateRequest.routing(grandParentId); updateRequest.routing(parentId); updateRequest.doc(fields); result.add(updateRequest); Loading Loading
src/main/java/es/redmic/elasticsearchlib/common/repository/RBaseESRepository.java +6 −20 Original line number Diff line number Diff line Loading @@ -308,14 +308,10 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte protected abstract JavaType getSourceType(Class<?> wrapperClass); protected GetResponse getRequest(String id) { return getRequest(id, null, null); return getRequest(id, null); } protected GetResponse getRequest(String id, String parentId) { return getRequest(id, parentId, null); } protected GetResponse getRequest(String id, String parentId, String grandparentId) { LOGGER.debug("FindById en " + getIndex() + " " + getType() + " con id " + id); Loading @@ -324,10 +320,7 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte GetRequest getRequest = new GetRequest(getIndex()[i], getType(), id.toString()); if (parentId != null) { getRequest.parent(parentId); } if (grandparentId != null) { getRequest.routing(grandparentId); getRequest.routing(parentId); } GetResponse response; Loading @@ -335,7 +328,7 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte response = ESProvider.getClient().get(getRequest, RequestOptions.DEFAULT); } catch (IOException e) { e.printStackTrace(); throw new ItemNotFoundException("id", id + " en el servicio " + getType()); throw new ItemNotFoundException("id", id + " en el servicio " + getIndex()[i] + " - " + getType()); } if (response != null && response.isExists()) { Loading @@ -343,7 +336,7 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte } } throw new ItemNotFoundException("id", id + " en el servicio " + getType()); throw new ItemNotFoundException("id", id + " en el servicio " + getIndex()[0] + " - " + getType()); } public List<String> suggest(TQueryDTO queryDTO) { Loading Loading @@ -412,11 +405,6 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte protected MultiGetResponse multigetRequest(MgetDTO dto, String parentId) { return multigetRequest(dto, parentId, null); } protected MultiGetResponse multigetRequest(MgetDTO dto, String parentId, String grandParentId) { LOGGER.debug("Mget en " + getIndex() + " " + getType() + " con fields " + dto.getFields() + " e ids " + dto.getIds()); Loading @@ -438,11 +426,9 @@ public abstract class RBaseESRepository<TModel extends BaseES<?>, TQueryDTO exte Item item = new Item(getIndex()[i], getType(), dto.getIds().get(k)); if (parentId != null) { item.parent(parentId); } if (grandParentId != null) { item.routing(grandParentId); item.routing(parentId); } item.fetchSourceContext(fetchSourceContext); request.add(item); } Loading
src/main/java/es/redmic/elasticsearchlib/common/utils/ElasticPersistenceUtils.java +6 −15 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { .setRefreshPolicy(RefreshPolicy.IMMEDIATE); if (parentId != null) { request.parent(parentId); request.routing(parentId); } // @formatter:on Loading Loading @@ -105,7 +105,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { .setRefreshPolicy(RefreshPolicy.IMMEDIATE); if (parentId != null) { updateRequest.parent(parentId); updateRequest.routing(parentId); } // @formatter:on Loading Loading @@ -139,7 +139,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { // @formatter:on if (parentId != null) { updateRequest.parent(parentId); updateRequest.routing(parentId); } try { Loading @@ -162,7 +162,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { DeleteRequest deleteRequest = new DeleteRequest(index, type, id).setRefreshPolicy(RefreshPolicy.IMMEDIATE); if (parentId != null) { deleteRequest.parent(parentId); deleteRequest.routing(parentId); } try { Loading @@ -181,18 +181,12 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { public List<UpdateRequest> getUpdateRequest(String[] index, String[] type, String id, Map<String, Object> fields) { return getUpdateRequest(index, type, id, fields, null, null); return getUpdateRequest(index, type, id, fields, null); } public List<UpdateRequest> getUpdateRequest(String[] index, String[] type, String id, Map<String, Object> fields, String parentId) { return getUpdateRequest(index, type, id, fields, parentId, null); } public List<UpdateRequest> getUpdateRequest(String[] index, String[] type, String id, Map<String, Object> fields, String parentId, String grandParentId) { List<UpdateRequest> result = new ArrayList<UpdateRequest>(); for (int i = 0; i < index.length; i++) { Loading @@ -203,10 +197,7 @@ public class ElasticPersistenceUtils<TModel extends BaseES<?>> { updateRequest.id(id); updateRequest.fetchSource(true); if (parentId != null) updateRequest.parent(grandParentId); if (grandParentId != null) updateRequest.routing(grandParentId); updateRequest.routing(parentId); updateRequest.doc(fields); result.add(updateRequest); Loading