def parse_query_part(part, query_classes={}, prefixes={}, default_class=query.SubstringQuery):
 part = part.strip()
 match = PARSE_QUERY_PART_REGEX.match(part)
 assert match
 negate = bool(match.group(1))
 key = match.group(2)
 term = match.group(3).replace('\\:', ':')
 for (pre, query_class) in prefixes.items():
  if term.startswith(pre):
   return (key, term[len(pre):], query_class, negate)
 query_class = query_classes.get(key, default_class)
 return (key, term, query_class, negate)

def parse_query_part ( part , query_classes = { } , prefixes = { } , default_class = query . SubstringQuery ) : part = part . strip ( ) match = PARSE_QUERY_PART_REGEX . match ( part ) assert match negate = bool ( match . group ( 1 ) ) key = match . group ( 2 ) term = match . group ( 3 ) . replace ( '\\:' , ':' ) for ( pre , query_class ) in prefixes . items ( ) : if term . startswith ( pre ) : return ( key , term [ len ( pre ) : ] , query_class , negate ) query_class = query_classes . get ( key , default_class ) return ( key , term , query_class , negate )
parse a single *query part* .