#NEWLINE# def build_analyzer( analyzer , plain = True ) : #NEWLINE# #INDENT# if callable ( analyzer ) : #NEWLINE# #INDENT# return analyzer #NEWLINE# #UNINDENT# cached = ANALYZER_CACHE . get ( analyzer ) #NEWLINE# if ( cached is not None ) : #NEWLINE# #INDENT# return cached #NEWLINE# #UNINDENT# if ( analyzer . startswith ( 'es://' ) or analyzer . startswith ( 'ess://' ) ) : #NEWLINE# #INDENT# values = analyzer . split ( '://' ) [ 1 ] . split ( '/' ) #NEWLINE# if ( ( len ( values ) != 3 ) and ( len ( values ) != 4 ) ) : #NEWLINE# #INDENT# raise ValueError ( 'Invalid parameters: {0}' . format ( analyzer ) ) #NEWLINE# #UNINDENT# if analyzer . startswith ( 'ess://' ) : #NEWLINE# #INDENT# host = 'https://{0}' . format ( values [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# host = values [ 0 ] #NEWLINE# #UNINDENT# cached = ElasticsearchAnalyzer ( host = host , index = values [ 1 ] , analyzer = values [ 2 ] ) #NEWLINE# if plain : #NEWLINE# #INDENT# cached = ElasticsearchTextAnalyzer ( cached ) #NEWLINE# #UNINDENT# ANALYZER_CACHE [ analyzer ] = cached #NEWLINE# return analyzer #NEWLINE# #UNINDENT# raise ValueError ( ( '%s is not implemented.' % analyzer ) )