def ac(self, **params): """Autocomplete API. """ field = params['field'] term = params['term'] colls = params['colls'].split(",") # FIXME - allow restricting search to a set of collections if field == '*': return jsonresp([]) fieldname, fieldtype = field.rsplit('_', 1) fieldconfigs = SearchCollection.config['types'] \ .get('record', {}) \ .get('fields', {}) if '*' in colls: target = SearchCollection.all() else: target = SearchCollection.field.coll.is_or_is_descendant(colls) return jsonresp( field_item_types[fieldtype] .autocomplete(target, fieldconfigs, fieldname, term) )