Buggy code:
public class UserFactory extends AbstractIndexFactory < UserEntry > implements IndexFactory < UserEntry > { public static final String field_screen_name = "screen_name" ; public static final String field_user_id = "user_id" ; public static final String field_name = "name" ; public static final String field_profile_image_url_http = "profile_image_url_http" ; public static final String field_profile_image_url_https = "profile_image_url_https" ; public static final String field_profile_image = "profile_image" ; public static final String field_appearance_first = "appearance_first" ; public static final String field_appearance_latest = "appearance_latest" ; public UserFactory ( final Client elasticsearch_client , final String index_name , final int cacheSize ) { } @ Override public XContentBuilder getMapping ( ) { try { <START_BUG> XContentBuilder mapping = XContentFactory . jsonBuilder ( ) . startObject ( ) . startObject ( "properties" ) . startObject ( UserFactory . field_screen_name ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_name ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . endObject ( ) . startObject ( UserFactory . field_user_id ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_appearance_first ) . field ( "type" , "date" ) . field ( "format" , "dateOptionalTime" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_appearance_latest ) . field ( "type" , "date" ) . field ( "format" , "dateOptionalTime" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_profile_image_url_http ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_profile_image_url_https ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_profile_image ) . field ( "type" , "binary" ) . field ( "index" , "no" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . endObject ( ) . endObject ( ) ; <END_BUG> return mapping ; } catch ( IOException e ) { e . printStackTrace ( ) ; return null ; } } @ Override public UserEntry init ( Map < String , Object > map ) { } public UserEntry init ( JSONObject json ) { } No newline ; at end ; of file ; }

Fix:
XContentBuilder mapping = XContentFactory . jsonBuilder ( ) . startObject ( ) . startObject ( "properties" ) . startObject ( UserFactory . field_screen_name ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_name ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "analyzed" ) . endObject ( ) . startObject ( UserFactory . field_user_id ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_appearance_first ) . field ( "type" , "date" ) . field ( "format" , "dateOptionalTime" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_appearance_latest ) . field ( "type" , "date" ) . field ( "format" , "dateOptionalTime" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_profile_image_url_http ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_profile_image_url_https ) . field ( "type" , "string" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . startObject ( UserFactory . field_profile_image ) . field ( "type" , "binary" ) . field ( "index" , "no" ) . field ( "include_in_all" , "false" ) . field ( "index" , "not_analyzed" ) . endObject ( ) . endObject ( ) . endObject ( ) ;