Azure搜索,映射,合并集合

问题描述 投票:0回答:1

我有以下数据:

来自SELECT c.addresses[0] address, [ c.name ] filenames FROM c

[
  {
    "address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "filenames": [
      "File 01.docx"
    ]
  },
  {
    "address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "filenames": [
      "File 02.docx"
    ]
  },
  {
    "address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "filenames": [
      "File 03.docx"
    ]
  }, ....

address字段是关键,我有一个索引,其字段定义如下:

new Field()
{
    Name = "filenames",
    Type = DataType.Collection(DataType.String),
    IsSearchable = true,
    IsFilterable = true,
    IsSortable = false,
    IsFacetable = false
},

如您所见,我使用[ c.name ] filenames为文件名创建了一个数组。

当我索引上面显示的数据时,索引在文件名集合中包含一行,该行是已编入索引的最后一行。我可以将它添加到集合(合并)而不是替换吗?

我也在考虑使用Query来解决这个问题,但是CosmosDB不支持subselect(还),而UDF只能看到传递给它的数据。

azure azure-search
1个回答
1
投票

从根本上说,构建Cosmos DB集合的方式使得此方案无法工作,因为Azure搜索不支持合并到集合中。

考虑改变你的设计,使address成为集合中的一个关键(即唯一),所有filenames都按照address收集在一个文档中:

  {
    "address": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "filenames": [ "File 01.docx", "File 02.docx", "File 03.docx", ... ]
  }

另外,请在Azure Search UserVoice site上添加一个建议,以添加对合并集合的支持,这将使您的场景更容易实现。

© www.soinside.com 2019 - 2024. All rights reserved.