def search(spec, operator='<STR_LIT>'):
field_map = {<EOL>'<STR_LIT:name>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>}<EOL>query_filter = None<EOL>for field, values in spec.items():<EOL><INDENT>for value in values:<EOL><INDENT>if field not in field_map:<EOL><INDENT>continue<EOL><DEDENT>field_filter = Q(**{field_map[field]: value})<EOL>if not query_filter:<EOL><INDENT>query_filter = field_filter<EOL>continue<EOL><DEDENT>if operator == '<STR_LIT>':<EOL><INDENT>query_filter &= field_filter<EOL><DEDENT>else:<EOL><INDENT>query_filter |= field_filter<EOL><DEDENT><DEDENT><DEDENT>result = []<EOL>packages = models.Package.objects.filter(query_filter).all()[:<NUM_LIT:20>]<EOL>for package in packages:<EOL><INDENT>release = package.releases.all()[<NUM_LIT:0>]<EOL>result.append({<EOL>'<STR_LIT:name>': package.name,<EOL>'<STR_LIT>': release.summary,<EOL>'<STR_LIT:version>': release.version,<EOL>'<STR_LIT>': <NUM_LIT:0>,<EOL>})<EOL><DEDENT>return result<EOL>
Implement xmlrpc search command.

    This only searches through the mirrored and private packages