Skip to content

Commit 17bd4cc

Browse files
author
Jenkins Continuous Integration Server
committed
Upgrade ES 2.0
1 parent 7781621 commit 17bd4cc

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

elasticsearch-mapping/src/main/java/org/elasticsearch/mapping/FieldsMappingBuilder.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.lang.annotation.Annotation;
77
import java.lang.reflect.InvocationTargetException;
88
import java.lang.reflect.Field;
9+
import java.lang.reflect.Method;
910
import java.lang.reflect.Modifier;
1011
import java.util.*;
1112

@@ -459,18 +460,27 @@ private Map<String, PropertyDescriptor> getValidPropertyDescriptorMap(Class<?> c
459460
@SuppressWarnings("unchecked")
460461
public String getIdValue (Object obj) throws IntrospectionException, IllegalAccessException, InvocationTargetException,
461462
NoSuchMethodException {
462-
String value = null;
463-
Class<?> clazz = obj.getClass();
464-
List<Indexable> indexables = getIndexables(clazz);
463+
String value = null;
464+
Class<?> clazz = obj.getClass();
465+
List<Indexable> indexables = getIndexables(clazz);
466+
467+
for (Indexable indexable : indexables) {
468+
Id id = indexable.getAnnotation(Id.class);
469+
if (id != null) {
470+
String name = indexable.getName();
471+
value = (String)(PropertyUtils.getSimpleProperty(obj, name));
472+
}
473+
}
465474

466-
for (Indexable indexable : indexables) {
467-
Id id = indexable.getAnnotation(Id.class);
468-
if (id != null) {
469-
String name = indexable.getName();
470-
value = (String)(PropertyUtils.getSimpleProperty(obj, name));
471-
}
472-
}
473-
return value;
475+
if (value == null) {
476+
try {
477+
Method getIdMethod = clazz.getMethod ("getId");
478+
Object oresult = getIdMethod.invoke(obj);
479+
value = (String)oresult;
480+
} catch (Exception e) {}
474481
}
475482

483+
return value;
484+
}
485+
476486
}

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
<artifactId>jna</artifactId>
4040
<version>${jna.version}</version>
4141
</dependency>
42-
4342
<dependency>
4443
<groupId>org.apache.lucene</groupId>
4544
<artifactId>lucene-expressions</artifactId>

0 commit comments

Comments
 (0)