question: private Dictionary loadDictionary ( String locale , Settings nodeSettings , Environment env ) throws Exception { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Loading hunspell dictionary [{}]..." , locale ) ; } Path dicDir = hunspellDir . resolve ( locale ) ; if ( FileSystemUtils . isAccessibleDirectory ( dicDir , logger ) == false ) { throw new ElasticsearchException ( String . format ( Locale . ROOT , "Could not find hunspell dictionary [%s]" , locale ) ) ; } nodeSettings = loadDictionarySettings ( dicDir , nodeSettings . getByPrefix ( "indices.analysis.hunspell.dictionary." + locale + "." ) ) ; boolean ignoreCase = nodeSettings . getAsBoolean ( "ignore_case" , defaultIgnoreCase ) ; Path [ ] affixFiles = FileSystemUtils . files ( dicDir , "*.aff" ) ; if ( affixFiles . length == 0 ) { throw new ElasticsearchException ( String . format ( Locale . ROOT , "Missing affix file for hunspell dictionary [%s]" , locale ) ) ; } if ( affixFiles . length != 1 ) { throw new ElasticsearchException ( String . format ( Locale . ROOT , "Too many affix files exist for hunspell dictionary [%s]" , locale ) ) ; } InputStream affixStream = null ; Path [ ] dicFiles = FileSystemUtils . files ( dicDir , "*.dic" ) ; List < InputStream > dicStreams = new ArrayList < > ( dicFiles . length ) ; try { for ( int i = 0 ; i < dicFiles . length ; i ++ ) { dicStreams . add ( Files . newInputStream ( dicFiles [ i ] ) ) ; } affixStream = Files . newInputStream ( affixFiles [ 0 ] ) ; return new Dictionary ( affixStream , dicStreams , ignoreCase ) ; } catch ( Exception e ) { logger . error ( "Could not load hunspell dictionary [{}]" , e , locale ) ; throw e ; } finally { if ( affixStream != null ) { try { affixStream . close ( ) ; } catch ( IOException e ) { } } for ( InputStream in : dicStreams ) { if ( in != null ) { try { in . close ( ) ; } catch ( IOException e ) { } } } } }
target:  Loads the hunspell dictionary for the given local.