【问题标题】:create azure search index on azure blob storage containing plain text files and search在包含纯文本文件和搜索的 azure blob 存储上创建 azure 搜索索引
【发布时间】:2020-02-25 00:37:24
【问题描述】:

我创建了一个 Azure 搜索服务并且知道 this。但是,此链接处理半结构化数据。如何在 C# 中以编程方式设置文本文件的索引,类似于this?我还想知道如何将 Azure 搜索服务与我的 blob 存储相关联,还是自动完成?谢谢。

【问题讨论】:

    标签: c# azure azure-blob-storage azure-search-.net-sdk


    【解决方案1】:

    如果您遵循第一个链接中的方法,则需要将 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 上也有可用的方法:

    https://docs.microsoft.com/en-us/azure/search/tutorial-multiple-data-sources#create-blob-storage-data-source-and-indexer

    【讨论】:

    • 正如我所说,我想索引纯文本文件而不是 JSON,或者您是否建议我需要这种格式并且内容包含文本?
    • 其实重读第一个链接,我觉得值得为我的文本文件创建POCOs/JSON。
    猜你喜欢
    • 2020-03-03
    • 2016-08-14
    • 2023-01-05
    • 2018-03-16
    • 2018-04-30
    • 2021-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多