Set Edm.ComplexType in Azure Search by SDK

LABIDI Skander 1 Reputation point
2020-12-09T08:52:00.717+00:00

I have a problem in Azure search, I get data from a csv file in blob storage. To simplify let assume my object as:

public class Instrument
{
public Identifier Identifier { get; set; }

[SearchableField(IsSortable = true, IsKey = true)]
public string Id { get; set; }

[SearchableField(IsSortable = true)]
public string RefIs { get; set; }

}

public class Identifier
{
[SearchableField(IsSortable = true)]
public string Code { get; set; }

}
when I receive my data it's flat in the csv such as : _id,_ref,_code.

When I create my index through SDK I setup Mapping for simple Fields:

    indexer.FieldMappings.Add(new FieldMapping("_ref")
    {
        TargetFieldName = "RefIs"
    });

but I cannot figure out the way I declare it to complex type in my indexer ? given code does not work for it :

    indexer.FieldMappings.Add(new FieldMapping("_code")
    {
        TargetFieldName = "Code"  
    });

    indexer.FieldMappings.Add(new FieldMapping("_code")
    {
        TargetFieldName = "Identifier.Code"  
    });

error is the same TargetField is not present in index.

Could someone help ?

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
834 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 19,921 Reputation points
    2020-12-10T15:03:39.96+00:00

    Thanks for asking question! Could you please try to use a / rather than a . in the TargetFieldName . For example

    TargetFieldName = "Identifier/Code"

    This assumes Code is actually a subfield of the Identifier Complex Collection data type.

    Let us know.