def test_search(self):
        for idx, content in enumerate(self.corpus):
            self.index.index(content=content)

        def assertSearch(phrase, indexes, ranking=RANK_BM25):
            results = [doc.content
                       for doc in self.index.search(phrase, ranking)]
            self.assertEqual(results, [self.corpus[idx] for idx in indexes])

        assertSearch('believe', [3, 0])
        assertSearch('faith man', [0])
        if IS_FTS5:
            assertSearch('faith thing', [4, 2])
        else:
            assertSearch('faith thing', [2, 4])
        assertSearch('things', [4, 2])
        assertSearch('blah', [])
        self.assertRaises(InvalidSearchException, self.index.search, '')

        assertSearch('believe', [3, 0], RANK_BM25)  # Same result.
        if IS_FTS5:
            assertSearch('faith thing', [4, 2], RANK_BM25)  # Swapped.
        else:
            assertSearch('faith thing', [2, 4], RANK_BM25)  # Same.
        assertSearch('things', [4, 2], RANK_BM25)  # Same result.
        assertSearch('blah', [], RANK_BM25)  # No results, works.
        self.assertRaises(
            InvalidSearchException, self.index.search, '', RANK_BM25)
Ensure the result has a 'user' key.
dataset/ETHPy150Open coleifer/scout/tests.py/TestModelAPIs.test_search--crossover with--dataset/ETHPy150Open django-json-api/django-rest-framework-json-api/example/tests/test_model_viewsets.py/ModelViewSetTests.test_key_in_detail_result