(query, limit=10, page=1, ix=None, fields=None, reverse=False, sortedby=[], **kwargs)
return hits
Query search index
Query search index
Query search index
def whoosh_search(query, limit=10, page=1, ix=None, fields=None, reverse=False, sortedby=[], **kwargs):
    """
    Query search index
    """

    fields = fields or ['tags', 'title', 'content', 'author']
    ix = ix or init_index()
    searcher = ix.searcher()

    # Splits the query into words and applies
    # and OR filter, eg. 'foo bar' == 'foo OR bar'
    orgroup = OrGroup

    parser = MultifieldParser(fieldnames=fields, schema=ix.schema, group=orgroup).parse(query)

    hits = searcher.search_page(parser,pagenum=page, pagelen=limit, reverse=reverse, sortedby=sortedby, **kwargs)
    hits.results.fragmenter.maxchars = 100
    hits.results.fragmenter.surround = 100

    return hits
def whoosh_search ( query , limit = 10 , page = 1 , ix = None , fields = None , reverse = False , sortedby = [ ] , * * kwargs ) : fields = fields or [ 'tags' , 'title' , 'content' , 'author' ] ix = ix or init_index ( ) searcher = ix . searcher ( ) # Splits the query into words and applies # and OR filter, eg. 'foo bar' == 'foo OR bar' orgroup = OrGroup parser = MultifieldParser ( fieldnames = fields , schema = ix . schema , group = orgroup ) . parse ( query ) hits = searcher . search_page ( parser , pagenum = page , pagelen = limit , reverse = reverse , sortedby = sortedby , * * kwargs ) hits . results . fragmenter . maxchars = 100 hits . results . fragmenter . surround = 100 return hits