'Uses the leg search to map topics to bills.'

def get_bill_topics(self, chamber, session):

    search_chamber = {'lower': 'House', 'upper': 'Senate'}[chamber]
    search_session = self.search_session(session)
    self._subject_mapping = defaultdict(list)
    url = ('%sstatus_search.php?body=%s&search=topic&session=%s' % (BILL_DETAIL_URL_BASE, search_chamber, search_session))
    html = self.get(url).text
    doc = lxml.html.fromstring(html)
    if self.is_testing():
        option_set = doc.xpath('//select[@name="topic[]"]/option')[0:5]
    else:
        option_set = doc.xpath('//select[@name="topic[]"]/option')[0:]
    for option in option_set:
        subject = option.text.rsplit('    (')[0]
        value = option.get('value')
        opt_url = ('%sstatus_result.php?body=%s&search=topic&session=%s&topic[]=%s&submit_topic=GO' % (BILL_DETAIL_URL_BASE, search_chamber, search_session, value))
        opt_html = self.get(opt_url).text
        opt_doc = lxml.html.fromstring(opt_html)
        for bill in opt_doc.xpath('//table/tbody/tr/td[2]/a/text()'):
            bill = self.make_bill_id(bill)
            self._subject_mapping[bill].append(subject)
