【发布时间】:2020-02-25 00:37:24
【问题描述】:
我创建了一个 Azure 搜索服务并且知道 this。但是,此链接处理半结构化数据。如何在 C# 中以编程方式设置文本文件的索引,类似于this?我还想知道如何将 Azure 搜索服务与我的 blob 存储相关联,还是自动完成?谢谢。
【问题讨论】:
标签: c# azure azure-blob-storage azure-search-.net-sdk
我创建了一个 Azure 搜索服务并且知道 this。但是,此链接处理半结构化数据。如何在 C# 中以编程方式设置文本文件的索引,类似于this?我还想知道如何将 Azure 搜索服务与我的 blob 存储相关联,还是自动完成?谢谢。
【问题讨论】:
标签: c# azure azure-blob-storage azure-search-.net-sdk
如果您遵循第一个链接中的方法,则需要将 Hotel 模型更改为如下所示:
public class BlobModel
{
[JsonProperty("@search.score")]
public float searchscore { get; set; }
[JsonProperty("content")]
public string Content { get; set; }
[JsonProperty("metadata_storage_content_type")]
public string MetadataStorageContentType { get; set; }
[JsonProperty("metadata_storage_size")]
public int MetadataStorageSize { get; set; }
[JsonProperty("metadata_storage_last_modified")]
public DateTime MetadataStorageLastModified { get; set; }
[JsonProperty("metadata_storage_content_md5")]
public string MetadataStorageContentMd5 { get; set; }
[JsonProperty("metadata_storage_name")]
public string MetadataStorageName { get; set; }
[JsonProperty("metadata_storage_path")]
public string MetadataStoragePath { get; set; }
[JsonProperty("metadata_title")]
public string MetadataTitle { get; set; }
[JsonProperty("metadata_content_encoding")]
public string MetadataContentEncoding { get; set; }
}
请注意,您需要手动填充所有这些属性,除非您使用索引器,它会自动将存储绑定到您的索引(如第二个链接中所述)。如果您不想使用 REST API,Azure 认知搜索 SDK 上也有可用的方法:
【讨论】: