Skip to content

Stage 5, Enrich with AI ​

At a glance ​

Start stateEnd stateFallback baseline
A searchable base indexAn enriched index with entities and key phrasesStage 5 enriched index + skillset + indexer

Learning goals ​

  • Add a skillset with entity recognition (Person, Organization, Location) and key-phrase extraction.
  • Map skill outputs to new index fields with output field mappings.
  • Reset and rerun the indexer so existing records pick up the enrichment.

Why it matters ​

Plain text search finds records that contain a word. Enrichment tells you who and what a record is about. Once the archive knows that a memo mentions Alan Prentice, the Scranton branch, and the theme "printer outage", you can facet and filter on those values instead of guessing at keywords.

What you will build ​

A skillset tNN-pNN-corporate-skillset with two cognitive skills, four new collection fields on your index (people, organizations, locations, keyPhrases), indexer output field mappings that route skill results into those fields, and a reset-and-rerun of your indexer to populate them.

Knowledge-share outline ​

  1. What a skillset is and where AI enrichment sits in the indexing pipeline (datasource, then skillset, then index).
  2. Entity recognition (Person, Organization, Location) and key-phrase extraction over /document/content.
  3. Output field mappings and why you must reset the indexer before rerunning it.

How enrichment fits the pipeline ​

The indexer already reads each record from blob storage and maps fields into your index. A skillset adds a middle step: the indexer sends content to AI skills, the skills return structured values (entities and phrases), and output field mappings write those values into new index fields.

The Search service reaches the AI skills through its managed identity (Cognitive Services User on the shared Foundry resource). There is no key and no endpoint secret in your workflow.

Lab steps ​

Work in the Azure portal on your own Search service.

1. Extend the index with enrichment fields ​

Open Indexes > tNN-pNN-corporate-index > Edit JSON, and add these four fields to the end of the fields array. Each is a string collection because a record can mention several people, organizations, or locations; each is searchable, filterable, and facetable so you can both search and group by them. Save when you are done.

json
{ "name": "people", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "facetable": true, "retrievable": true },
{ "name": "organizations", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "facetable": true, "retrievable": true },
{ "name": "locations", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "facetable": true, "retrievable": true },
{ "name": "keyPhrases", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "facetable": true, "retrievable": true }

Adding new fields to an existing index is allowed and does not touch the documents already in it. (Changing an existing field's attributes is the thing that is not allowed.)

Reference copy: definitions/enriched-index.template.json.

2. Create the skillset ​

On your Search service:

  1. Select Skillsets in the left-hand navigation.
  2. Select + Add skillset.
  3. The new skillset opens in a JSON editor. Replace the skeleton with the full definition below, substituting tNN-pNN with your own namespace. Replace subdomainUrl with the Foundry endpoint on the Session values page. This shared endpoint changes every time the workshop is redeployed.
json
{
  "name": "tNN-pNN-corporate-skillset",
  "description": "Enrich corporate archive records with recognized entities and key phrases.",
  "skills": [
    {
      "@odata.type": "#Microsoft.Skills.Text.V3.EntityRecognitionSkill",
      "name": "entity-recognition",
      "description": "Extract people, organizations, and locations from record content.",
      "categories": [ "Person", "Organization", "Location" ],
      "defaultLanguageCode": "en",
      "context": "/document",
      "inputs": [ { "name": "text", "source": "/document/content" } ],
      "outputs": [
        { "name": "persons", "targetName": "people" },
        { "name": "organizations", "targetName": "organizations" },
        { "name": "locations", "targetName": "locations" }
      ]
    },
    {
      "@odata.type": "#Microsoft.Skills.Text.KeyPhraseExtractionSkill",
      "name": "key-phrases",
      "description": "Extract the main themes from record content.",
      "defaultLanguageCode": "en",
      "context": "/document",
      "inputs": [ { "name": "text", "source": "/document/content" } ],
      "outputs": [ { "name": "keyPhrases", "targetName": "keyPhrases" } ]
    }
  ],
  "cognitiveServices": {
    "@odata.type": "#Microsoft.Azure.Search.AIServicesByIdentity",
    "subdomainUrl": "https://aif-dmsearch-xxxxxx.services.ai.azure.com/",
    "identity": null
  }
}

The two skills both read /document/content: entity recognition extracts Person, Organization, and Location categories, renaming its persons output to people so it lines up with the index field you just added; key phrase extraction extracts the record's themes into keyPhrases. The cognitiveServices block is the Cognitive Services connection, wired to the Search service's own managed identity against the shared Foundry resource, so the skillset carries no key.

  1. Select Save to create the skillset.

Reference copy: definitions/skillset.template.json.

3. Wire the skillset and output mappings into the indexer ​

Open your indexer tNN-pNN-corporate-indexer > Edit JSON and:

  1. Set its skillset to tNN-pNN-corporate-skillset.
  2. Add output field mappings that route the enrichment from the document tree into your fields:
json
"outputFieldMappings": [
  { "sourceFieldName": "/document/people",        "targetFieldName": "people" },
  { "sourceFieldName": "/document/organizations", "targetFieldName": "organizations" },
  { "sourceFieldName": "/document/locations",     "targetFieldName": "locations" },
  { "sourceFieldName": "/document/keyPhrases",    "targetFieldName": "keyPhrases" }
]

Then Save. Reference copy: definitions/indexer.template.json.

4. Reset and rerun the indexer ​

Existing records were already indexed before the skillset existed, so they carry no enrichment yet. Reset the indexer (this clears its change-tracking high-water mark), then Run it. On the rerun, every record flows through the skillset and the new fields fill in.

Watch the indexer until it reports success and a document count of 132.

This run is not instant, and the whole room is sharing one model

Every record now makes two AI calls, so a full run is 264 calls per attendee against a Foundry resource the entire room shares. Expect a minute or two, and longer if everyone resets at the same moment.

Wait for your facilitator's signal before you select Run. Thirty simultaneous resets is how a room throttles itself; staggered across a minute, nobody notices. If you do get a rate-limit warning, wait a few seconds and run again rather than retrying in a tight loop, and move on to reading step 5 while it works rather than refreshing.

5. Search and filter the enriched values ​

Use Search explorer on your index, then select View > JSON view. For each query, replace the entire request with the JSON shown and select Search.

Find every record associated with a real employee from the archive. Alan Prentice turns up in the Scranton and Buffalo printer records; the enrichment surfaces him in the people field:

json
{
  "search": "*",
  "queryType": "simple",
  "filter": "people/any(person: person eq 'Alan Prentice')",
  "select": "recordId,subject,branch,people,locations"
}

Ask which people are associated with fire-safety records. Search the theme, then read the people and locations that enrichment attached:

json
{
  "search": "fire safety",
  "queryType": "simple",
  "select": "recordId,subject,branch,people,locations,keyPhrases"
}

Facet by extracted people to see who shows up most across the archive:

json
{
  "search": "*",
  "queryType": "simple",
  "facets": ["people,count:10"]
}

Inspect a single record's enrichment. Bianca Rao runs the Harborview Realty account out of Stamford and shows up in sales notes across several branches; pull one and read what the skills extracted:

json
{
  "search": "Bianca Rao",
  "queryType": "simple",
  "select": "recordId,subject,people,organizations,locations,keyPhrases"
}

Expected output ​

  • The people filter for Alan Prentice returns his printer records with people and locations populated.
  • The fire-safety search returns records whose people and locations name the employees and branches involved (for example Priya Nair, Albany, and Stamford).
  • The people facet returns a ranked list of extracted names with counts.
  • A single Bianca Rao record shows non-empty people, organizations, locations, and keyPhrases collections (the client name is what lands in organizations).

Exact extracted values depend on the AI skills, so treat these as recognizable, not exactly reproducible.

Checkpoint ​

enrichment-ready: Your index has populated people, organizations, locations, and keyPhrases fields, and you can filter or facet on an extracted entity (for example, list every record whose people include Alan Prentice, or facet the archive by people).

Fallback baseline ​

Every piece of this stage is a JSON paste, so the fallback is the same three pastes from known-good files. In the portal, under your own namespace only:

  1. Index > tNN-pNN-corporate-index > Edit JSON: take the four enrichment fields from baseline/5/index.json.
  2. Skillsets > Add skillset: paste baseline/5/skillset.json, replacing {{namespace}} with your tNN-pNN and {{foundryEndpoint}} with the Foundry endpoint from the Session values page (for example https://aif-dmsearch-xxxxxx.services.ai.azure.com/).
  3. Indexers > tNN-pNN-corporate-indexer > Edit JSON: take skillsetName and outputFieldMappings from baseline/5/indexer.json.

Then Reset and Run the indexer once so the enrichment populates.

Troubleshooting ​

  • Enrichment fields are empty after a run. You probably ran the indexer without resetting it first, so it skipped already-indexed records. Reset the indexer, then run it again.
  • Indexer errors mentioning Cognitive Services or access. The Search service managed identity needs Cognitive Services User on the shared Foundry resource (the workshop grants this). Confirm the skillset uses the AIServicesByIdentity connection, not a key.
  • Output mapping produces no values. Check the source paths: entity outputs live at /document/people, /document/organizations, /document/locations, and key phrases at /document/keyPhrases. A typo in the path silently yields empty fields.
  • A filter returns nothing. Collection filters use any, for example "filter": "people/any(person: person eq 'Alan Prentice')", and values are case-sensitive.

What we will not cover ​

  • Custom skills or Web API skills; this stage stays on the built-in entity and key-phrase skills.
  • Text-split or chunking skills; the archive records are small and need no splitting.