Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
add parent fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gkozyryatskyy committed Dec 7, 2016
1 parent 0989e60 commit 6375ab6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/main/java/com/escli4j/mapping/Mapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ protected boolean createIndex(String index, Map<String, Class<? extends EsEntity
Type typeAmmotation = entry.getValue().getAnnotation(Type.class);
if (typeAmmotation.create()) {
execute = true;
builder.addMapping(entry.getKey(), MappingUtils.getMappingBuilder(entry.getKey(), entry.getValue()));
builder.addMapping(entry.getKey(),
MappingUtils.getMappingBuilder(entry.getKey(), typeAmmotation.parent(), entry.getValue()));
}
}
// not send get request if execute == false
Expand All @@ -99,9 +100,10 @@ protected boolean updateIndex(String index, Map<String, Class<? extends EsEntity
Type typeAmmotation = entry.getValue().getAnnotation(Type.class);
if (typeAmmotation.update()) {
execute = true;
result &= client.admin().indices().preparePutMapping(index).setType(entry.getKey())
.setSource(MappingUtils.getMappingBuilder(entry.getKey(), entry.getValue())).get()
.isAcknowledged();
result &= client.admin().indices()
.preparePutMapping(index).setType(entry.getKey()).setSource(MappingUtils
.getMappingBuilder(entry.getKey(), typeAmmotation.parent(), entry.getValue()))
.get().isAcknowledged();
}
}
return execute && result;
Expand Down

0 comments on commit 6375ab6

Please sign in to comment.