'Interprets the collected query metadata and builds the final query to
be sent to the backend.'

def build_query(self):

    final_query = self.query_filter.as_query_string(self.build_query_fragment)
    if (not final_query):
        final_query = self.matching_all_fragment()
    if self.boost:
        boost_list = []
        for (boost_word, boost_value) in self.boost.items():
            boost_list.append(self.boost_fragment(boost_word, boost_value))
        final_query = (u'%s    %s' % (final_query, u'    '.join(boost_list)))
    return final_query
