def advanced_search(pattern):
 query_parsed = QUERY.parseString(pattern)
 return Entry.published.filter(query_parsed[0]).distinct()

def advanced_search ( pattern ) : query_parsed = QUERY . parseString ( pattern ) return Entry . published . filter ( query_parsed [ 0 ] ) . distinct ( )
parse the grammar of a pattern and build a queryset with it .