简体   繁体   English

使用DocumentDb作为服务资源创建azure搜索服务?

[英]Creating azure search service with DocumentDb as resource for service?

I already set up DocumentDb and uploaded the documents to DocumentDb. 我已经设置了DocumentDb,并将文档上传到DocumentDb。

My JSON documents have data nested upto 4 levels, eg:- 我的JSON文档最多嵌套了4个数据,例如:

{
  id: '12345',
  properties:
  {
      Accessories:
      {
            watch:1,
            WristBands: [{
                  blue:1, 
                  red: 2}]
                  }
            }
  Name: Leo,
  Age: 24
}

I want to use azure search service for able to search upto the last level(eg The count of wristband colour ie blue:1). 我想使用azure搜索服务来搜索到最后一级(例如,腕带颜色的计数,即blue:1)。 I have setup the service as well. 我也已经设置了服务。

I want some help in creating the index and the indexer for such nested data in C# so that I can query the service. 我需要一些帮助来为C#中的此类嵌套数据创建索引和索引器,以便我可以查询服务。 Already found, how to use DataType.Collection(DataType.String), but this supports till level 2. 已经找到了如何使用DataType.Collection(DataType.String),但这支持直到级别2。

Classes can also be made for each sub-level but have no idea how to define them during indexing. 也可以为每个子级别创建类,但不知道如何在索引期间定义它们。 Refered to example https://github.com/Azure-Samples/search-dotnet-getting-started . 参考示例https://github.com/Azure-Samples/search-dotnet-getting-started

Unfortunately, Azure Search does not support nested documents. 不幸的是,Azure搜索不支持嵌套文档。 As you can see from our Uservoice page, this by far the most requested feature so it is something that we are very interested in adding (please cast your vote here if you don't mind). 正如您在Uservoice页面上所看到的那样 ,这是迄今为止最受欢迎的功能,因此我们非常有兴趣添加此功能(如果您不介意,请在此处进行投票)。 Unfortunately, we do not yet have a timeline on when we will have it implemented yet. 不幸的是,我们尚无时间表何时实施。

In the meantime, for some applications it is realistic to either flatten the JSON documents or to leverage collection types. 同时,对于某些应用程序,将JSON文档展平或利用集合类型是现实的。 For more details on flattening documents, Kirk Evans has a really good blog post on the topic. 有关拼合文档的更多详细信息,柯克·埃文斯(Kirk Evans)撰写了有关该主题的非常好的博客文章

One more tutorial on setting up Azure Search indexer for DocumentDB: https://azure.microsoft.com/en-us/documentation/articles/documentdb-search-indexer/ . 有关为DocumentDB设置Azure搜索索引器的另一指南: https : //azure.microsoft.com/zh-cn/documentation/articles/documentdb-search-indexer/

+1 on Kirk Evans' blog post, which shows how to flatten the JSON document. 柯克·埃文斯(Kirk Evans)的博客文章中的+1,其中显示了如何展平JSON文档。 The idea is to leverage the optional query property under container in the data source creation request, and use a join query in that place. 这个想法是利用数据源创建请求中容器下的可选查询属性,并在该位置使用联接查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM