I am trying to create an index for my project to elasticsearch.
following are my classes
public class Asset
{
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public AssetComponent Component { get; set; }
public AssetSite Site { get; set; }
public AssetComposition AssetComposition { get; set; }
public string SerialNumber { get; set; }
public string WorkOrderNumber { get; set; }
public AssetFigure Figure {get;set;}
public string SkuNumber { get; set; }
public Status AssetStatus { get; set; }
public Status InspectionStatus { get; set; }
public BsonDocument UserDefinedAttributes { get; set; }
public TimeAndUserTrail Trail { get; set; }
[BsonIgnoreIfDefault]
public List<Identifier> Identifiers { get; set; } = new List<Identifier>();
[BsonIgnoreIfDefault]
public List<Document> Documents { get; set; } = new List<Document>();
public Status OrderStatus { get; set; }
}
public class AssetComponent
{
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public string Name { get; set; }
}
public class AssetSite
{
[BsonRepresentation(BsonType.ObjectId)]
public string LocationId { get; set; }
[BsonRepresentation(BsonType.ObjectId)]
public string SiteId { get; set; }
}
public class AssetComposition
{
public List<AssetComponentComposition> SubAssemblies { get; set; }
public List<AssetComponentComposition> Parts { get; set; }
public List<AssetComponentComposition> Accessories { get; set; }
}
public class AssetComponentComposition
{
public string Name { get; set; }
public string AssetType { get; set; }
public List<ObjectId> AssetIds { get; set; }
}
public class AssetFigure
{
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public string Name { get; set; }
}
public class Status
{
public string Id { get; set; }
public string Value { get; set; }
}
And in elasticsearch create index method
var createIndexResponse = client.CreateIndex(indexName, c => c
.Mappings(ms => ms
.Map<Asset>(m => m
.AutoMap<AssetComposition>()
.AutoMap<AssetComponent>()
.AutoMap<AssetSite>()
.AutoMap<AssetFigure>()
.AutoMap<BsonDocument>()
.AutoMap<TimeAndUserTrail>()
.AutoMap<Core.Entities.Status>()
.AutoMap(typeof(AssetComponentComposition))
.AutoMap(typeof(Identifier))
.AutoMap(typeof(Document))
.AutoMap(typeof(ObjectId))
)
)
);
When I run this, I am getting the following exception. System.Reflection.AmbiguousMatchException: 'Ambiguous match found.' I tried to resolve this using the following link from elasticsearch official document https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/auto-map.html
But again I didn't resolved the issue. Please help.