def test_generate_and_terms_for_lexical_search(self):
        """Test to ensure that the AND terms are correctly built when searchable attributes are specified.
        """
        test_cases = [
            (
                ["required_1"], ['lexical_field_1'],
                '(marqo__lexical_lexical_field_1 contains "required_1")',
                "Simple 1 required term, 1 field"
            ),
            (
                ["required_1", "required_2"], ['lexical_field_1'],
                '(marqo__lexical_lexical_field_1 contains "required_1") AND '
                '(marqo__lexical_lexical_field_1 contains "required_2")',
                "2 required terms, 1 field"
            ),
            (
                ["required_1", "required_2"], ['lexical_field_1', 'lexical_field_2'],
                '(marqo__lexical_lexical_field_1 contains "required_1" '
                'OR marqo__lexical_lexical_field_2 contains "required_1") AND '
                '(marqo__lexical_lexical_field_1 contains "required_2" '
                'OR marqo__lexical_lexical_field_2 contains "required_2")',
                "2 required terms, 2 fields"
            ),
            (
                ["long required phrase", "short required phrase"], ['lexical_field_1', 'lexical_field_4'],
                '(marqo__lexical_lexical_field_1 contains "long required phrase" '
                'OR marqo__lexical_lexical_field_4 contains "long required phrase") AND '
                '(marqo__lexical_lexical_field_1 contains "short required phrase" OR '
                'marqo__lexical_lexical_field_4 contains "short required phrase")',
                "2 multiple words required phrases, 2 fields"
            ),
            (
                ["term1", "term2"], None,
                'default contains "term1" AND default contains "term2"',
                "2 required terms, no fields"
            ),
            (
                ["term1", "term2", "term3", "term4"], ['lexical_field_1', 'lexical_field_2', 'lexical_field_3'],
                '(marqo__lexical_lexical_field_1 contains "term1" OR marqo__lexical_lexical_field_2 contains "term1" '
                'OR marqo__lexical_lexical_field_3 contains "term1") AND (marqo__lexical_lexical_field_1 contains "term2" '
                'OR marqo__lexical_lexical_field_2 contains "term2" OR marqo__lexical_lexical_field_3 contains "term2") AND '
                '(marqo__lexical_lexical_field_1 contains "term3" OR marqo__lexical_lexical_field_2 contains "term3" OR '
                'marqo__lexical_lexical_field_3 contains "term3") AND (marqo__lexical_lexical_field_1 contains "term4" '
                'OR marqo__lexical_lexical_field_2 contains "term4" OR marqo__lexical_lexical_field_3 contains "term4")',
                "4 required terms, 3 fields"
            )
        ]
        for required_phrases, searchable_attributes, expected_and_terms, msg in test_cases:
            with self.subTest(f"{msg}"):
                test_marqo_query = self._help_create_test_lexical_query_object(
                    or_phrases=[],
                    and_phrases=required_phrases,
                    searchable_attributes=searchable_attributes
                )
                generated_and_terms = self.structured_vespa_index._get_lexical_search_term(
                    test_marqo_query
                )
                self.assertEqual(generated_and_terms, expected_and_terms)
Test to ensure that the AND terms are correctly built when searchable attributes are specified.
        
tests/unit_tests/marqo/core/structured_vespa_index/test_structured_index_build_search_query.py