def prepare(self, query_obj):
    query_string = super(ElasticSearchExtendedAutoQuery, self).prepare(query_obj)
    if (not has_balanced_parentheses(query_string)):
        query_string = query_string.translate(self.to_be_removed_special_chars_translation_table)
    exacts = self.exact_match_re.findall(query_string)
    tokens = []
    query_bits = []
    for rough_token in self.exact_match_re.split(query_string):
        if (not rough_token):
            continue
        elif (rough_token not in exacts):
            tokens.extend(rough_token.split(' '))
        else:
            tokens.append(rough_token)
    for token in tokens:
        if (not token):
            continue
        if (token in exacts):
            query_bits.append(Exact(token, clean=True).prepare(query_obj))
        elif (token in self.uncleaned_tokens):
            query_bits.append(token)
        else:
            query_bits.append(Clean(token).prepare(query_obj))
    return u' '.join(query_bits)
def prepare(self, query_obj):
    query_string = super(ElasticSearchExtendedAutoQuery, self).prepare(query_obj)
    if (not has_balanced_parentheses(query_string)):
        query_string = query_string.translate(self.to_be_removed_special_chars_translation_table)
    exacts = self.exact_match_re.findall(query_string)
    tokens = []
    query_bits = []
    for rough_token in self.exact_match_re.split(query_string):
        if (not rough_token):
            continue
        elif (rough_token not in exacts):
            tokens.extend(rough_token.split(' '))
        else:
            tokens.append(rough_token)
    for token in tokens:
        if (not token):
            continue
        if (token in exacts):
            query_bits.append(Exact(token, clean=True).prepare(query_obj))
        elif (token in self.uncleaned_tokens):
            query_bits.append(token)
        else:
            query_bits.append(Clean(token).prepare(query_obj))
    return u' '.join(query_bits)