Azure 搜索索引中可以有不同的数据结构吗?

It is possible to have varying data structures in an Azure search index?

以下是我放入 Azure 搜索索引中的一些数据:

我可以使用这种严格的结构,但它需要支持不同的数据类型。我可以继续添加字段——即 Field4、Field5 ……但我想知道我是否可以添加类似 JSON 字段的内容?所以索引可以像下面这样建模:

[
  {
     "entityId":"dba656d3-f044-4cc0-9930-b5e77e664a8f",
     "entityName":"character",
     "data":{
        "name":"Luke Skywalker",
        "role":"Jedi"
     }
  },
  {
     "entityId":"b37bf987-0978-4fc4-9a51-b02b4a5eed53",
     "entityName":"character",
     "data":{
        "name":"C-3PO",
        "role":"Droid"
     }
  },
  {
     "entityId":"b161b9dc-552b-4744-b2d7-4584a9673669",
     "entityName":"film",
     "data":{
        "name":"A new hope"
     }
  },
  {
     "entityId":"e59acdaf-5bcd-4536-a8e9-4f3502cc7d85",
     "entityName":"film",
     "data":{
        "name":"The Empire Strikes Back"
     }
  },
  {
     "entityId":"00501b4a-5279-41e9-899d-a914ddcc562e",
     "entityName":"vehicle",
     "data":{
        "name":"Sand Crawler",
        "model":"Digger Crawler",
        "manufacturer":"Corellia Mining Corporation"
     }
  },
  {
     "entityId":"fe815cb6-b03c-401e-a871-396f2cd3eaba",
     "entityName":"vehicle",
     "data":{
        "name":"TIE/LN starfighter",
        "model":"win Ion Engine/Ln Starfighter",
        "manufacturer":"Sienar Fleet Systems"
     }
  }

]

我知道我可以将 JSON 放在字符串字段中,但这会对搜索匹配和过滤产生负面影响。

这在 Azure 搜索中是否可行,或者是否有其他方法可以实现这种要求?

参见文章 How to model complex data types。我相信酒店示例数据可以很好地转化为您的用例。如果您的不同实体具有不同的属性集,您可以创建类似于下面的地址或便利设施示例的“复杂类型”。

Structural updates

You can add new sub-fields to a complex field at any time without the need for an index rebuild. For example, adding "ZipCode" to Address or "Amenities" to Rooms is allowed, just like adding a top-level field to an index.

 {
  "HotelId": "1",
  "HotelName": "Secret Point Motel",
  "Description": "Ideally located on the main commercial artery of the city in the heart of New York.",
  "Tags": ["Free wifi", "on-site parking", "indoor pool", "continental breakfast"]
  "Address": {
    "StreetAddress": "677 5th Ave",
    "City": "New York",
    "StateProvince": "NY"
  },
  "Rooms": [
    {
      "Description": "Budget Room, 1 Queen Bed (Cityside)",
      "RoomNumber": 1105,
      "BaseRate": 96.99,
    },
    {
      "Description": "Deluxe Room, 2 Double Beds (City View)",
      "Type": "Deluxe Room",
      "BaseRate": 150.99,
    }
    . . .
  ]
}