def whooshee_search(self, search_string, group=whoosh.qparser.OrGroup, whoosheer=None,<EOL>match_substrings=True, limit=None, order_by_relevance=<NUM_LIT:10>):
if not whoosheer:<EOL><INDENT>entities = set()<EOL>for cd in self.column_descriptions:<EOL><INDENT>entities.add(cd['<STR_LIT:type>'])<EOL><DEDENT>if self._join_entities and isinstance(self._join_entities[<NUM_LIT:0>], Mapper):<EOL><INDENT>entities.update(set([x.entity for x in self._join_entities]))<EOL><DEDENT>else:<EOL><INDENT>entities.update(set(self._join_entities))<EOL><DEDENT>unaliased = set()<EOL>for entity in entities:<EOL><INDENT>if isinstance(entity, (AliasedClass, AliasedInsp)):<EOL><INDENT>unaliased.add(inspect(entity).mapper.class_)<EOL><DEDENT>else:<EOL><INDENT>unaliased.add(entity)<EOL><DEDENT><DEDENT>whoosheer = next(w for w in _get_config(self)['<STR_LIT>']<EOL>if set(w.models) == unaliased)<EOL><DEDENT>for fname, field in list(whoosheer.schema._fields.items()):<EOL><INDENT>if field.unique:<EOL><INDENT>uniq = fname<EOL><DEDENT><DEDENT>res = whoosheer.search(search_string=search_string,<EOL>values_of=uniq,<EOL>group=group,<EOL>match_substrings=match_substrings,<EOL>limit=limit)<EOL>if not res:<EOL><INDENT>return self.filter(text('<STR_LIT:null>'))<EOL><DEDENT>attr = None<EOL>if hasattr(whoosheer, '<STR_LIT>'):<EOL><INDENT>attr = getattr(whoosheer.models[<NUM_LIT:0>], uniq)<EOL><DEDENT>else:<EOL><INDENT>for m in whoosheer.models:<EOL><INDENT>if m.__name__.lower() == uniq.split('<STR_LIT:_>')[<NUM_LIT:0>]:<EOL><INDENT>attr = getattr(m, uniq.split('<STR_LIT:_>')[<NUM_LIT:1>])<EOL><DEDENT><DEDENT><DEDENT>search_query = self.filter(attr.in_(res))<EOL>if order_by_relevance < <NUM_LIT:0>: <EOL><INDENT>search_query = search_query.order_by(sqlalchemy.sql.expression.case(<EOL>[(attr == uniq_val, index) for index, uniq_val in enumerate(res)],<EOL>))<EOL><DEDENT>elif order_by_relevance > <NUM_LIT:0>: <EOL><INDENT>search_query = search_query.order_by(sqlalchemy.sql.expression.case(<EOL>[(attr == uniq_val, index) for index, uniq_val in enumerate(res) if index < order_by_relevance],<EOL>else_=order_by_relevance<EOL>))<EOL><DEDENT>else: <EOL><INDENT>pass<EOL><DEDENT>return search_query<EOL>
Do a fulltext search on the query.
        Returns a query filtered with results of the fulltext search.

        :param search_string: The string to search for.
        :param group: The whoosh group to use for searching.
                      Defaults to :class:`whoosh.qparser.OrGroup` which
                      searches for all words in all columns.
        :param match_substrings: ``True`` if you want to match substrings,
                                 ``False`` otherwise
        :param limit: The number of the top records to be returned.
                      Defaults to ``None`` and returns all records.