Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Latest commit

 

History

History
102 lines (89 loc) · 2.69 KB

File metadata and controls

102 lines (89 loc) · 2.69 KB
topic languages products name description azureDeploy
sample
csharp
azure-cognitive-services
Get File Extension sample skill for cognitive search
This custom skill returns the document's extension and file name without extension.

GetFileExtension

This custom skill returns the document's file extension and the file name without extension to be indexed accordingly.

Deploy to Azure

Requirements

These skills have no additional requirements than the ones described in the root README.md file.

Sample Input:

{
    "values": [
        {
            "recordId": "1",
            "data":
            {
                "documentName":  "2020_quarterly_earnings.docx",
            }
        },
        {
            "recordId": "foo1",
            "data":
            {
                "documentName":  "IMPORTANT_COMPANY_ANNOUNCEMENT.eml",
            }
        }
    ]
}

Sample Output:

{
    "values": [
        {
            "recordId": "1",
            "data": {
                "extensions" : ".docx",
                "fileName" : "2020_quarterly_earnings"
            },
            "errors": [],
            "warnings": []
        },
        {
            "recordId": "foo1",
            "data": {
                "extensions" : ".eml",
                "fileName" : "IMPORTANT_COMPANY_ANNOUNCEMENT"
            },
            "errors": [],
            "warnings": []
        }
    ]
}

Sample Skillset Integration

In order to use this skill in a cognitive search pipeline, you'll need to add a skill definition to your skillset. Here's a sample skill definition for this example (inputs and outputs should be updated to reflect your particular scenario and skillset environment):

{
    "@odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
    "description": "Our Custom Get File Extension custom skill",
    "context": "/document",
    "uri": "[AzureFunctionEndpointUrl]/api/get-file-extension?code=[AzureFunctionDefaultHostKey]",
    "batchSize": 1,
    "inputs": [
        {
            "name": "documentName",
            "source": "/document/metadata_storage_name/"
        }
    ],
    "outputs": [
        {
            "name": "extension",
            "targetName": "extension"
        },
        {
            "name": "fileName",
            "targetName": "fileName"
        }
    ]
}