in Elastic.SemanticKernel.Connectors.Elasticsearch/ElasticsearchGenericDataModelMapper.cs [85:122]
public VectorStoreGenericDataModel<string> MapFromStorageToDataModel((string? id, JsonObject document) storageModel,
StorageToDataModelMapperOptions options)
{
Verify.NotNull(storageModel);
var dataModel = new VectorStoreGenericDataModel<string>(storageModel.id!);
foreach (var item in _propertyToStorageName)
{
var property = item.Key;
var storageModelPropertyName = item.Value;
if (!storageModel.document.TryGetPropertyValue(storageModelPropertyName, out var value))
{
// Just skip this property if it's not in the storage model.
continue;
}
var targetDictionary = property switch
{
VectorStoreRecordKeyProperty => null,
VectorStoreRecordVectorProperty => dataModel.Vectors,
VectorStoreRecordDataProperty => dataModel.Data,
_ => throw new NotSupportedException($"Property of type '{property.GetType().Name}' is not supported.")
};
if (targetDictionary is null)
{
continue;
}
targetDictionary[property.DataModelPropertyName] = value is null
? null
: _elasticsearchClientSettings.SourceSerializer.Deserialize(value, property.PropertyType);
}
return dataModel;
}