79091082

Date: 2024-10-15 17:26:42
Score: 0.5
Natty:
Report link

Had to change a few things but it is working as expected now.

Firstly, had to add index projections to the skillset and explicitly map all fields I want to populate in the search index. Note that contentVector does not show up in search index because it is not retrievable.

skillset = SearchIndexerSkillset(
        name="cf-chunk-embed-skillset",
        description="Skillset for chunking and Azure OpenAI embeddings",
        skills=[split_skill, embedding_skill],
        index_projection=SearchIndexerIndexProjection(
            selectors=[
                SearchIndexerIndexProjectionSelector(
                    target_index_name="cf-rag-index",
                    parent_key_field_name="parent_id",
                    source_context="/document/chunks/*",
                    mappings=[
                        InputFieldMappingEntry(name="chunk", source="/document/chunks/*"),
                        InputFieldMappingEntry(name="contentVector", source="/document/chunks/*/contentVector"),
                        InputFieldMappingEntry(name="title", source="/document/title"),
                        InputFieldMappingEntry(name="abstract", source="/document/abstract"),
                        InputFieldMappingEntry(name="summary", source="/document/summary"),
                        InputFieldMappingEntry(name="jurisdiction", source="/document/jurisdiction"),
                        InputFieldMappingEntry(name="category", source="/document/category"),
                        InputFieldMappingEntry(name="location", source="/document/location"),
                        InputFieldMappingEntry(name="document_type", source="/document/document_type"),
                    ]
                )
            ],
            parameters=SearchIndexerIndexProjectionsParameters(
                projection_mode="skipIndexingParentDocuments"
            )
        )
    )

Also needed to create a new parent id field and modify the key field to have keyword analyzer.

fields = [
        SearchField(name="id", type=SearchFieldDataType.String, key=True, analyzer_name="keyword"),
        SimpleField(name="parent_id", type=SearchFieldDataType.String, filterable=True),
        SearchableField(name="title", type=SearchFieldDataType.String),
        # SearchableField(name="content", type=SearchFieldDataType.String),
        SearchableField(name="chunk", type=SearchFieldDataType.String),
        SimpleField(name="location", type=SearchFieldDataType.String, filterable=True),
        SimpleField(name="document_type", type=SearchFieldDataType.String, filterable=True),
        SearchableField(name="jurisdiction", collection=True, type=SearchFieldDataType.String, filterable=True),
        SearchableField(name="category", collection=True, type=SearchFieldDataType.String, filterable=True),
        SearchableField(name="summary", type=SearchFieldDataType.String),
        SearchableField(name="abstract", type=SearchFieldDataType.String),
        SearchField(name="contentVector", type=SearchFieldDataType.Collection(SearchFieldDataType.Single),
                    searchable=True, vector_search_dimensions=3072, vector_search_profile_name="cf-vector"),
    ]

Lastly, you can remove the output field mappings from the search indexer. It didn't seem to do anything when the index projection is set on the skillset.

Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: cap