'Azure Cognitive Search: How to index json custom metadata of a blob

I have a blob with a custom metadata property of jsonmd. The custom metadata looks something like:

{
    "ResourceName": "ipso factum...",
    "ResourceVariations": [{
        "Description": "ipso factum...",
        "Name": "R4.mp4",
        "Thumbnail": "R4.jpg",
        "URL": ""
    },
    ...

I was able to capture the full json in the index by including a filed in the index:

    {
      "name": "jsonmd",
      "type": "Edm.String",
      "facetable": true,
      "filterable": true,
      ...

I want to capture the Thumbnail property and have added this field to the index:

    {
      "name": "Thumbnail",
      "type": "Edm.String",
      "facetable": true,
      "filterable": true,
      "key": false,
      "retrievable": true,
      "searchable": true,
      "sortable": true,
      "analyzer": "standard.lucene",
      "indexAnalyzer": null,
      "searchAnalyzer": null,
      "synonymMaps": [],
      "fields": []
    }

I can't figure out how to use the custom metadata (jsonmd) to populate the Thumbnail property of the index?



Solution 1:[1]

You can define complex types in your index schema. Below is an example of how I collect metadata from PDF documents that we index. I extract the properties from the PDF using regular C# code, populate a Dictionary and then submit the objects using the Azure Cognitive Search SDK.

For more examples, see Model complex data types in Azure Cognitive Search.

{
  "name": "Metadata",
  "type": "Edm.ComplexType",
  "analyzer": null,
  "synonymMaps": [],
  "fields": [
    {
      "name": "Properties",
      "type": "Collection(Edm.ComplexType)",
      "analyzer": null,
      "synonymMaps": [],
      "fields": [
        {
          "name": "Name",
          "type": "Edm.String",
          "facetable": true,
          "filterable": true,
          "key": false,
          "retrievable": true,
          "searchable": true,
          "sortable": false,
          "analyzer": "pattern",
          "indexAnalyzer": null,
          "searchAnalyzer": null,
          "synonymMaps": [],
          "fields": []
        },
        {
          "name": "Values",
          "type": "Collection(Edm.String)",
          "facetable": true,
          "filterable": true,
          "retrievable": true,
          "searchable": true,
          "analyzer": "pattern",
          "indexAnalyzer": null,
          "searchAnalyzer": null,
          "synonymMaps": [],
          "fields": []
        }
      ]
    }
  ]
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dan Gøran Lunde