1

I am new to Azure Search. I have been trying to create a new index which includes DataType.Complex for one of the fields. Microsoft provides an example of how to create a new index with DataType.Complex, but for the suggester.

Here is the REQUEST BODY that Microsoft documentation shows as an example, but I am not too sure how to add a sub-field of a complex type in the suggester. Is there way to do it?

  "name": "hotels",  
  "fields": [
    { "name": "HotelId", "type": "Edm.String", "key": true, "filterable": true },
    { "name": "HotelName", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": true, "facetable": false },
    { "name": "Description", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft" },
    { "name": "Description_fr", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "fr.microsoft" },
    { "name": "Category", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true },
    { "name": "Tags", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "tagsAnalyzer" },
    { "name": "ParkingIncluded", "type": "Edm.Boolean", "filterable": true, "sortable": true, "facetable": true },
    { "name": "LastRenovationDate", "type": "Edm.DateTimeOffset", "filterable": true, "sortable": true, "facetable": true },
    { "name": "Rating", "type": "Edm.Double", "filterable": true, "sortable": true, "facetable": true },
    { "name": "Address", "type": "Edm.ComplexType", 
      "fields": [
          { "name": "StreetAddress", "type": "Edm.String", "filterable": false, "sortable": false, "facetable": false, "searchable": true },
          { "name": "City", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true },
          { "name": "StateProvince", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true },
          { "name": "PostalCode", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true },
          { "name": "Country", "type": "Edm.String", "searchable": true, "filterable": true, "sortable": true, "facetable": true }
        ]
    },
    { "name": "Location", "type": "Edm.GeographyPoint", "filterable": true, "sortable": true },
    { "name": "Rooms", "type": "Collection(Edm.ComplexType)", 
      "fields": [
          { "name": "Description", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.lucene" },
          { "name": "Description_fr", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "fr.lucene" },
          { "name": "Type", "type": "Edm.String", "searchable": true },
          { "name": "BaseRate", "type": "Edm.Double", "filterable": true, "facetable": true },
          { "name": "BedOptions", "type": "Edm.String", "searchable": true },
          { "name": "SleepsCount", "type": "Edm.Int32", "filterable": true, "facetable": true },
          { "name": "SmokingAllowed", "type": "Edm.Boolean", "filterable": true, "facetable": true },
          { "name": "Tags", "type": "Collection(Edm.String)", "searchable": true, "filterable": true, "facetable": true, "analyzer": "tagsAnalyzer" }
        ]
    }
  ],
  "suggesters": [
    { "name": "sg", "searchMode": "analyzingInfixMatching", "sourceFields": ["HotelName"] }
  ],
  "analyzers": [
    {
      "@odata.type": "#Microsoft.Azure.Search.CustomAnalyzer",  
      "name": "tagsAnalyzer",
      "charFilters": [ "html_strip" ],  
      "tokenizer": "standard_v2"    
    }
  ]
}```
Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35
Kyle Ahn
  • 39
  • 4

1 Answers1

3

You can add subfields of a complex field to a suggester by specifying the full path to the subfield. For example, if you want to include the Description subfield of the Rooms collection, just add “Rooms/Description” to the list of fields in the suggester.

Bruce Johnston
  • 8,344
  • 3
  • 32
  • 42
  • So for example, the suggester JSON above would look like this, `"suggesters": [ { "name": "sg", "searchMode": "analyzingInfixMatching", "sourceFields": ["HotelName", "Rooms/Description"] } ]` Would this set the suggester? Rooms/Description sub-field to be true? – Kyle Ahn Aug 20 '19 at 00:17
  • Thanks a lot Bruce!! I really appreciate your help – Kyle Ahn Aug 20 '19 at 20:02
  • @jack.the.ripper Please keep comments focused on the topic of this answer. Somebody from my team has already been automatically assigned to answer your question; There is no need to @-mention us directly, especially since it makes it harder for other readers to follow the original discussion. – Bruce Johnston Aug 28 '19 at 17:09