<s> from operator import attrgetter <EOL> from olympia . amo . indexers import BaseSearchIndexer <EOL> class CollectionIndexer ( BaseSearchIndexer ) : <EOL> @ classmethod <EOL> def get_model ( cls ) : <EOL> from olympia . bandwagon . models import Collection <EOL> return Collection <EOL> @ classmethod <EOL> def get_mapping ( cls ) : <EOL> doc_name = cls . get_doctype_name ( ) <EOL> mapping = { <EOL> doc_name : { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT:float>' , '<STR_LIT>' : <NUM_LIT:1.0> } , <EOL> '<STR_LIT>' : { '<STR_LIT:type>' : '<STR_LIT:string>' , '<STR_LIT:index>' : '<STR_LIT>' } , <EOL> '<STR_LIT:name>' : { '<STR_LIT:type>' : '<STR_LIT:string>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> '<STR_LIT:description>' : { '<STR_LIT:type>' : '<STR_LIT:string>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> } , <EOL> } <EOL> } <EOL> cls . attach_language_specific_analyzers ( <EOL> mapping , ( '<STR_LIT:name>' , '<STR_LIT:description>' ) ) <EOL> return mapping <EOL> @ classmethod <EOL> def extract_document ( cls , obj ) : <EOL> attrs = ( '<STR_LIT:id>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:type>' , '<STR_LIT>' ) <EOL> data = dict ( zip ( attrs , attrgetter ( * attrs ) ( obj ) ) ) <EOL> data [ '<STR_LIT>' ] = data . pop ( '<STR_LIT>' ) <EOL> data [ '<STR_LIT>' ] = obj . subscribers ** <NUM_LIT> <EOL> if obj . listed : <EOL> data [ '<STR_LIT>' ] = max ( data [ '<STR_LIT>' ] , <NUM_LIT:1> ) * <NUM_LIT:4> <EOL> for field in ( '<STR_LIT:description>' , '<STR_LIT:name>' ) : <EOL> data . update ( cls . extract_field_search_translations ( obj , field ) ) <EOL> data . update ( cls . extract_field_analyzed_translations ( obj , field ) ) <EOL> data [ '<STR_LIT>' ] = unicode ( obj . name ) . lower ( ) <EOL> return data </s>
