private static boolean isInIgnoreFields(java.lang.reflect.Field field) { Field fieldAnnotation = field.getAnnotation(Field.class); if (null != fieldAnnotation) { String[] ignoreFields = fieldAnnotation.ignoreFields(); return Arrays.asList(ignoreFields).contains(field.getName()); } return false; }
/** * Apply mapping for a single @Field annotation * * @param xContentBuilder * @param field * @param fieldAnnotation * @throws IOException */ private static void addSingleFieldMapping( XContentBuilder xContentBuilder, java.lang.reflect.Field field, Field fieldAnnotation) throws IOException { xContentBuilder.startObject(field.getName()); xContentBuilder.field(FIELD_STORE, fieldAnnotation.store()); if (FieldType.Auto != fieldAnnotation.type()) { xContentBuilder.field(FIELD_TYPE, fieldAnnotation.type().name().toLowerCase()); if (FieldType.Date == fieldAnnotation.type() && DateFormat.none != fieldAnnotation.format()) { xContentBuilder.field( FIELD_FORMAT, DateFormat.custom == fieldAnnotation.format() ? fieldAnnotation.pattern() : fieldAnnotation.format()); } } if (FieldIndex.not_analyzed == fieldAnnotation.index()) { xContentBuilder.field(FIELD_INDEX, fieldAnnotation.index().name().toLowerCase()); } if (isNotBlank(fieldAnnotation.searchAnalyzer())) { xContentBuilder.field(FIELD_SEARCH_ANALYZER, fieldAnnotation.searchAnalyzer()); } if (isNotBlank(fieldAnnotation.indexAnalyzer())) { xContentBuilder.field(FIELD_INDEX_ANALYZER, fieldAnnotation.indexAnalyzer()); } xContentBuilder.endObject(); }