'Perform search on the in-memory index. Weight in the given boosts.'

def search(self, q, tool_name_boost, tool_section_boost, tool_description_boost, tool_label_boost, tool_stub_boost, tool_help_boost, tool_search_limit, tool_enable_ngram_search, tool_ngram_minsize, tool_ngram_maxsize):

    searcher = self.index.searcher(weighting=BM25F(field_B={'name_B': float(tool_name_boost), 'section_B': float(tool_section_boost), 'description_B': float(tool_description_boost), 'labels_B': float(tool_label_boost), 'stub_B': float(tool_stub_boost), 'help_B': float(tool_help_boost)}))
    parser = MultifieldParser(['name', 'description', 'section', 'help', 'labels', 'stub'], schema=self.schema)
    if (q.find('-') != (-1)):
        q = '    '.join([token.text for token in self.rex(to_unicode(q))])
    if ((tool_enable_ngram_search is True) or (tool_enable_ngram_search == 'True')):
        hits_with_score = {}
        token_analyzer = (StandardAnalyzer() | analysis.NgramFilter(minsize=int(tool_ngram_minsize), maxsize=int(tool_ngram_maxsize)))
        ngrams = [token.text for token in token_analyzer(q)]
        for query in ngrams:
            curr_hits = searcher.search(parser.parse((('*' + query) + '*')), limit=float(tool_search_limit))
            for (i, curr_hit) in enumerate(curr_hits):
                is_present = False
                for prev_hit in hits_with_score:
                    if (curr_hit['id'] == prev_hit):
                        is_present = True
                        hits_with_score[prev_hit] = (curr_hits.score(i) + hits_with_score[prev_hit])
                if (not is_present):
                    hits_with_score[curr_hit['id']] = curr_hits.score(i)
        hits_with_score = sorted(hits_with_score.items(), key=(lambda x: x[1]), reverse=True)
        return [item[0] for item in hits_with_score[0:int(tool_search_limit)]]
    else:
        hits = searcher.search(parser.parse((('*' + q) + '*')), limit=float(tool_search_limit))
        return [hit['id'] for hit in hits]
