@classmethod<EOL><INDENT>def search_bm25(cls, term, weights=None, with_score=False,<EOL>score_alias='<STR_LIT>', explicit_ordering=False):<DEDENT>
if not weights:<EOL><INDENT>rank = SQL('<STR_LIT>')<EOL><DEDENT>elif isinstance(weights, dict):<EOL><INDENT>weight_args = []<EOL>for field in cls._meta.sorted_fields:<EOL><INDENT>if isinstance(field, SearchField) and not field.unindexed:<EOL><INDENT>weight_args.append(<EOL>weights.get(field, weights.get(field.name, <NUM_LIT:1.0>)))<EOL><DEDENT><DEDENT>rank = fn.bm25(cls._meta.entity, *weight_args)<EOL><DEDENT>else:<EOL><INDENT>rank = fn.bm25(cls._meta.entity, *weights)<EOL><DEDENT>selection = ()<EOL>order_by = rank<EOL>if with_score:<EOL><INDENT>selection = (cls, rank.alias(score_alias))<EOL><DEDENT>if with_score and not explicit_ordering:<EOL><INDENT>order_by = SQL(score_alias)<EOL><DEDENT>return (cls<EOL>.select(*selection)<EOL>.where(cls.match(FTS5Model.clean_query(term)))<EOL>.order_by(order_by))<EOL>
Full-text search using selected `term`.