Malloy Documentation
search

Malloy has a special query operator that builds _Dimensional Search Indexes for sources. A Dimensional Search Index is a table with 4 columns. Dimensional indexes are useful for a variety of things including filtering suggestions and LLMs.

When filtering data, you might know a term, but not necessarily which column in the one of the join data contains it. Indexing the data on field names and high cardinality fields let's you qucikly find the term and the associated value.

Indexing could be used by LLMs to find the interesting column/term mapping in the data set.

  • fieldName - The path to the column in the source

  • fieldValue - The dimensional value for the field (or range if fieldType is not a string)

  • fieldType - Type type of the column.

  • weight - a weighting to use as to the importance the distinct dimensional value. Defaults to cardinality of the field.

Simple Example

We're going to take the airports table and index it. The results are an un ordered list of distinct fieldName/fieldValue pairs appear in the table. The weight, in this case is the number of rows that partciular occurs on.

document
run: duckdb.table('../data/airports.parquet') -> {
  index: *
}
QUERY RESULTS
fieldNamefieldPathfieldValuefieldTypeweight
act_dateact_datestring12,040
act_dateact_date02/2000string54
act_dateact_date11/1986string119
act_dateact_date11/1992string92
act_dateact_date10/1999string41
act_dateact_date12/1992string86
act_dateact_date09/1994string20
act_dateact_date08/1990string36
act_dateact_date01/1990string15
act_dateact_date08/1981string40
act_dateact_date12/1986string56
act_dateact_date11/1987string25
act_dateact_date04/1996string3
act_dateact_date01/1994string36
act_dateact_date04/1999string45
act_dateact_date03/1992string17
act_dateact_date07/1995string15
act_dateact_date04/1982string92
act_dateact_date05/1991string31
act_dateact_date03/1998string62
act_dateact_date01/1987string31
act_dateact_date05/1993string8
act_dateact_date02/1987string129
act_dateact_date10/1987string62
act_dateact_date09/1999string31
act_dateact_date07/1982string80
act_dateact_date01/1998string28
act_dateact_date04/1990string16
act_dateact_date12/1983string77
act_dateact_date12/1997string31
act_dateact_date09/1990string11
act_dateact_date07/1983string20
act_dateact_date09/1991string14
act_dateact_date09/1995string15
act_dateact_date05/1988string20
act_dateact_date06/2000string59
act_dateact_date06/1982string13
act_dateact_date11/1993string32
act_dateact_date11/1994string4
act_dateact_date10/1989string25
act_dateact_date10/1992string35
act_dateact_date02/1991string6
aero_chtaero_chtBETHELstring34
aero_chtaero_chtW ALEUTIAN ISLSstring3
aero_chtaero_chtATLANTAstring780
aero_chtaero_chtJACKSONVILLEstring467
aero_chtaero_chtKANSAS CITYstring713
aero_chtaero_chtHOUSTONstring765
aero_chtaero_chtLAS VEGASstring136
aero_chtaero_chtLOS ANGELESstring498
aero_chtaero_chtKLAMATH FALLSstring260
c_ldg_rtsc_ldg_rtsYstring283
cbd_dircbd_dirEstring2,127
cbd_dircbd_dirSEstring2,281
cbd_dircbd_dirNEstring2,393
cbd_dircbd_dirWstring2,065
cbd_dircbd_dirNNWstring11
cbd_dircbd_dirNNEstring13
certcertLU 06/1986string1
certcertCS 05/1973string84
certcertLS 05/1973string1
certcertAS 06/1987string1
certcertBS 03/1978string1
certcertCS 03/1973string1
certcertLU 01/1980string1
certcertLU 03/1999string1
certcertLU 06/1975string2
certcertDS 05/1973string26
citycityTAORA IS MALOELAP ATOLLstring1
citycityNAMORIK ATOLLstring1
citycityJABOR JALUIT ATOLLstring1
citycityROI-NAMURstring1
citycityJOHNSTON ISLANDstring1
citycityKWAJALEINstring1
citycityPALMERstring17
citycityDELTA JUNCTIONstring6
citycityHOMERstring10
citycityTRAPPER CREEK/TALKEETNAstring1
citycitySHAKTOOLIKstring1
citycityCAPE BEAUFORTstring1
citycityKAKEstring2
citycityLIME VILLAGEstring1
citycitySUTTONstring5
citycityDIOMEDEstring1
citycityHEALYstring3
citycitySHISHMAREFstring1
citycityCHALKYITSIKstring1
citycityNUNAPITCHUKstring1
citycityBIG MOUNTAINstring1
citycityOUZINKIEstring1
citycityST MICHAELstring1
citycityBIG LAKEstring5
citycityMC GRATHstring3
citycityATKAstring1
citycitySTEBBINSstring1
citycityCHEFORNAKstring1
citycityKODIAKstring5
citycityBOUNDARYstring1
citycityBREVIG MISSIONstring1
citycityNIKOLSKIstring1
[
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 12040
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "02/2000",
    "weight": 54
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "11/1986",
    "weight": 119
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "11/1992",
    "weight": 92
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "10/1999",
    "weight": 41
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "12/1992",
    "weight": 86
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "09/1994",
    "weight": 20
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "08/1990",
    "weight": 36
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "01/1990",
    "weight": 15
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "08/1981",
    "weight": 40
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "12/1986",
    "weight": 56
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "11/1987",
    "weight": 25
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "04/1996",
    "weight": 3
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "01/1994",
    "weight": 36
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "04/1999",
    "weight": 45
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "03/1992",
    "weight": 17
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "07/1995",
    "weight": 15
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "04/1982",
    "weight": 92
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "05/1991",
    "weight": 31
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "03/1998",
    "weight": 62
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "01/1987",
    "weight": 31
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "05/1993",
    "weight": 8
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "02/1987",
    "weight": 129
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "10/1987",
    "weight": 62
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "09/1999",
    "weight": 31
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "07/1982",
    "weight": 80
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "01/1998",
    "weight": 28
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "04/1990",
    "weight": 16
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "12/1983",
    "weight": 77
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "12/1997",
    "weight": 31
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "09/1990",
    "weight": 11
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "07/1983",
    "weight": 20
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "09/1991",
    "weight": 14
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "09/1995",
    "weight": 15
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "05/1988",
    "weight": 20
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "06/2000",
    "weight": 59
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "06/1982",
    "weight": 13
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "11/1993",
    "weight": 32
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "11/1994",
    "weight": 4
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "10/1989",
    "weight": 25
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "10/1992",
    "weight": 35
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": "02/1991",
    "weight": 6
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "BETHEL",
    "weight": 34
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "W ALEUTIAN ISLS",
    "weight": 3
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "ATLANTA",
    "weight": 780
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "JACKSONVILLE",
    "weight": 467
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "KANSAS CITY",
    "weight": 713
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "HOUSTON",
    "weight": 765
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "LAS VEGAS",
    "weight": 136
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "LOS ANGELES",
    "weight": 498
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "KLAMATH FALLS",
    "weight": 260
  },
  {
    "fieldName": "c_ldg_rts",
    "fieldPath": "c_ldg_rts",
    "fieldType": "string",
    "fieldValue": "Y",
    "weight": 283
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "E",
    "weight": 2127
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "SE",
    "weight": 2281
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "NE",
    "weight": 2393
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "W",
    "weight": 2065
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "NNW",
    "weight": 11
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "NNE",
    "weight": 13
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "LU 06/1986",
    "weight": 1
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "CS 05/1973",
    "weight": 84
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "LS 05/1973",
    "weight": 1
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "AS 06/1987",
    "weight": 1
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "BS 03/1978",
    "weight": 1
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "CS 03/1973",
    "weight": 1
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "LU 01/1980",
    "weight": 1
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "LU 03/1999",
    "weight": 1
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "LU 06/1975",
    "weight": 2
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": "DS 05/1973",
    "weight": 26
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "TAORA IS  MALOELAP ATOLL",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "NAMORIK ATOLL",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "JABOR JALUIT ATOLL",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "ROI-NAMUR",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "JOHNSTON ISLAND",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "KWAJALEIN",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "PALMER",
    "weight": 17
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "DELTA JUNCTION",
    "weight": 6
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "HOMER",
    "weight": 10
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "TRAPPER CREEK/TALKEETNA",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SHAKTOOLIK",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "CAPE BEAUFORT",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "KAKE",
    "weight": 2
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "LIME VILLAGE",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SUTTON",
    "weight": 5
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "DIOMEDE",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "HEALY",
    "weight": 3
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SHISHMAREF",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "CHALKYITSIK",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "NUNAPITCHUK",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "BIG MOUNTAIN",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "OUZINKIE",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "ST MICHAEL",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "BIG LAKE",
    "weight": 5
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "MC GRATH",
    "weight": 3
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "ATKA",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "STEBBINS",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "CHEFORNAK",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "KODIAK",
    "weight": 5
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "BOUNDARY",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "BREVIG MISSION",
    "weight": 1
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "NIKOLSKI",
    "weight": 1
  }
]
WITH __stage0 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'string'
      WHEN 1 THEN 'string'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'string'
      WHEN 4 THEN 'number'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'string'
      WHEN 7 THEN 'string'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'number'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
      WHEN 14 THEN 'string'
      WHEN 15 THEN 'string'
      WHEN 16 THEN 'string'
      WHEN 17 THEN 'string'
      WHEN 18 THEN 'number'
      WHEN 19 THEN 'string'
      WHEN 20 THEN 'number'
      WHEN 21 THEN 'number'
      WHEN 22 THEN 'string'
      WHEN 23 THEN 'string'
      WHEN 24 THEN 'string'
      WHEN 25 THEN 'string'
      WHEN 26 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 0 THEN base."act_date"
      WHEN 1 THEN base."aero_cht"
      WHEN 2 THEN base."c_ldg_rts"
      WHEN 3 THEN base."cbd_dir"
      WHEN 5 THEN base."cert"
      WHEN 6 THEN base."city"
      WHEN 7 THEN base."cntl_twr"
      WHEN 8 THEN base."code"
      WHEN 9 THEN base."county"
      WHEN 10 THEN base."cust_intl"
      WHEN 12 THEN base."faa_dist"
      WHEN 13 THEN base."faa_region"
      WHEN 14 THEN base."fac_type"
      WHEN 15 THEN base."fac_use"
      WHEN 16 THEN base."fed_agree"
      WHEN 17 THEN base."full_name"
      WHEN 19 THEN base."joint_use"
      WHEN 22 THEN base."major"
      WHEN 23 THEN base."mil_rts"
      WHEN 24 THEN base."own_type"
      WHEN 25 THEN base."site_number"
      WHEN 26 THEN base."state"
    END as "fieldValue",
   COUNT(*) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 4 THEN MIN(CAST(base."cbd_dist" as VARCHAR)) || ' to ' || CAST(MAX(base."cbd_dist") as VARCHAR)
      WHEN 11 THEN MIN(CAST(base."elevation" as VARCHAR)) || ' to ' || CAST(MAX(base."elevation") as VARCHAR)
      WHEN 18 THEN MIN(CAST(base."id" as VARCHAR)) || ' to ' || CAST(MAX(base."id") as VARCHAR)
      WHEN 20 THEN MIN(CAST(base."latitude" as VARCHAR)) || ' to ' || CAST(MAX(base."latitude") as VARCHAR)
      WHEN 21 THEN MIN(CAST(base."longitude" as VARCHAR)) || ' to ' || CAST(MAX(base."longitude") as VARCHAR)
    END as "fieldRange"
  FROM '../data/airports.parquet' as base
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,27,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
SELECT
  "fieldName",
  "fieldPath",
  "fieldType",
  COALESCE("fieldValue", "fieldRange") as "fieldValue",
  weight
FROM __stage0

Add Ordering

Adding a second query stage to filter on string columns and ordering by weight descending shows us the most common fieldName/fieldValue pairs in the dataset.

All Malloy queries run as a single SQL query. The index: operator is no different. Click the SQL tab to see how this works.

document
run: duckdb.table('../data/airports.parquet') -> {
  index: *
} -> {
  where: fieldType = 'string'
  select: *
  order_by: weight desc
}
QUERY RESULTS
fieldNamefieldPathfieldTypefieldValueweight
majormajorstringN19,523
certcertstring19,142
cntl_twrcntl_twrstringN19,124
fed_agreefed_agreestring16,252
cust_intlcust_intlstring15,145
c_ldg_rtsc_ldg_rtsstring15,145
joint_usejoint_usestring14,804
mil_rtsmil_rtsstring14,716
fac_usefac_usestringPR14,428
own_typeown_typestringPR14,306
fac_typefac_typestringAIRPORT13,925
act_dateact_datestring12,040
faa_distfaa_diststringNONE7,085
fac_usefac_usestringPU5,365
own_typeown_typestringPU5,174
fac_typefac_typestringHELIPORT5,135
joint_usejoint_usestringN4,779
cust_intlcust_intlstringN4,575
faa_regionfaa_regionstringAGL4,437
c_ldg_rtsc_ldg_rtsstringN4,365
cbd_dircbd_dirstringN3,694
faa_regionfaa_regionstringASW3,268
mil_rtsmil_rtsstringY2,958
faa_regionfaa_regionstringASO2,924
faa_regionfaa_regionstringAEA2,586
cbd_dircbd_dirstringNW2,438
cbd_dircbd_dirstringSW2,427
cbd_dircbd_dirstringNE2,393
cbd_dircbd_dirstringSE2,281
cbd_dircbd_dirstringS2,155
cbd_dircbd_dirstringE2,127
mil_rtsmil_rtsstringN2,119
faa_regionfaa_regionstringANM2,102
cbd_dircbd_dirstringW2,065
statestatestringTX1,845
fed_agreefed_agreestringNGY1,682
aero_chtaero_chtstringNEW YORK1,581
faa_regionfaa_regionstringACE1,579
faa_distfaa_diststringCHI1,528
faa_regionfaa_regionstringAWP1,503
aero_chtaero_chtstringCHICAGO1,480
aero_chtaero_chtstringDETROIT1,262
faa_distfaa_diststringDET1,240
faa_distfaa_diststringSEA1,162
faa_distfaa_diststringMSP1,046
faa_distfaa_diststringATL1,029
statestatestringCA984
faa_distfaa_diststringNYC957
faa_distfaa_diststringORL905
statestatestringIL890
aero_chtaero_chtstringDALLAS-FT WORTH888
aero_chtaero_chtstringWASHINGTON887
statestatestringFL856
aero_chtaero_chtstringST LOUIS847
faa_distfaa_diststringHAR846
statestatestringPA804
aero_chtaero_chtstringATLANTA780
aero_chtaero_chtstringHOUSTON765
faa_regionfaa_regionstringANE763
statestatestringOH749
aero_chtaero_chtstringSEATTLE749
aero_chtaero_chtstringKANSAS CITY713
aero_chtaero_chtstringTWIN CITIES699
faa_distfaa_diststringDEN679
cntl_twrcntl_twrstringY669
faa_distfaa_diststringDCA667
statestatestringIN643
aero_chtaero_chtstringCINCINNATI624
faa_distfaa_diststringBIS616
statestatestringAK608
faa_regionfaa_regionstringAAL608
aero_chtaero_chtstringMEMPHIS605
faa_distfaa_diststringSFO585
statestatestringNY576
aero_chtaero_chtstringOMAHA551
statestatestringWI543
statestatestringMO537
fed_agreefed_agreestringN515
statestatestringMN507
aero_chtaero_chtstringSAN ANTONIO503
faa_distfaa_diststringJAN502
statestatestringLA500
aero_chtaero_chtstringLOS ANGELES498
statestatestringMI489
faa_distfaa_diststringMEM487
statestatestringWA484
fac_typefac_typestringSEAPLANE BASE473
aero_chtaero_chtstringJACKSONVILLE467
aero_chtaero_chtstringNEW ORLEANS444
statestatestringOK443
statestatestringOR441
statestatestringGA440
statestatestringND436
aero_chtaero_chtstringSAN FRANCISCO427
statestatestringCO425
statestatestringVA421
aero_chtaero_chtstringGREEN BAY418
statestatestringKS415
statestatestringNC400
aero_chtaero_chtstringCHARLOTTE380
[
  {
    "fieldName": "major",
    "fieldPath": "major",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 19523
  },
  {
    "fieldName": "cert",
    "fieldPath": "cert",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 19142
  },
  {
    "fieldName": "cntl_twr",
    "fieldPath": "cntl_twr",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 19124
  },
  {
    "fieldName": "fed_agree",
    "fieldPath": "fed_agree",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 16252
  },
  {
    "fieldName": "cust_intl",
    "fieldPath": "cust_intl",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 15145
  },
  {
    "fieldName": "c_ldg_rts",
    "fieldPath": "c_ldg_rts",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 15145
  },
  {
    "fieldName": "joint_use",
    "fieldPath": "joint_use",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 14804
  },
  {
    "fieldName": "mil_rts",
    "fieldPath": "mil_rts",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 14716
  },
  {
    "fieldName": "fac_use",
    "fieldPath": "fac_use",
    "fieldType": "string",
    "fieldValue": "PR",
    "weight": 14428
  },
  {
    "fieldName": "own_type",
    "fieldPath": "own_type",
    "fieldType": "string",
    "fieldValue": "PR",
    "weight": 14306
  },
  {
    "fieldName": "fac_type",
    "fieldPath": "fac_type",
    "fieldType": "string",
    "fieldValue": "AIRPORT",
    "weight": 13925
  },
  {
    "fieldName": "act_date",
    "fieldPath": "act_date",
    "fieldType": "string",
    "fieldValue": null,
    "weight": 12040
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "NONE",
    "weight": 7085
  },
  {
    "fieldName": "fac_use",
    "fieldPath": "fac_use",
    "fieldType": "string",
    "fieldValue": "PU",
    "weight": 5365
  },
  {
    "fieldName": "own_type",
    "fieldPath": "own_type",
    "fieldType": "string",
    "fieldValue": "PU",
    "weight": 5174
  },
  {
    "fieldName": "fac_type",
    "fieldPath": "fac_type",
    "fieldType": "string",
    "fieldValue": "HELIPORT",
    "weight": 5135
  },
  {
    "fieldName": "joint_use",
    "fieldPath": "joint_use",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 4779
  },
  {
    "fieldName": "cust_intl",
    "fieldPath": "cust_intl",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 4575
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "AGL",
    "weight": 4437
  },
  {
    "fieldName": "c_ldg_rts",
    "fieldPath": "c_ldg_rts",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 4365
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 3694
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "ASW",
    "weight": 3268
  },
  {
    "fieldName": "mil_rts",
    "fieldPath": "mil_rts",
    "fieldType": "string",
    "fieldValue": "Y",
    "weight": 2958
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "ASO",
    "weight": 2924
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "AEA",
    "weight": 2586
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "NW",
    "weight": 2438
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "SW",
    "weight": 2427
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "NE",
    "weight": 2393
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "SE",
    "weight": 2281
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "S",
    "weight": 2155
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "E",
    "weight": 2127
  },
  {
    "fieldName": "mil_rts",
    "fieldPath": "mil_rts",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 2119
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "ANM",
    "weight": 2102
  },
  {
    "fieldName": "cbd_dir",
    "fieldPath": "cbd_dir",
    "fieldType": "string",
    "fieldValue": "W",
    "weight": 2065
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "TX",
    "weight": 1845
  },
  {
    "fieldName": "fed_agree",
    "fieldPath": "fed_agree",
    "fieldType": "string",
    "fieldValue": "NGY",
    "weight": 1682
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "NEW YORK",
    "weight": 1581
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "ACE",
    "weight": 1579
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "CHI",
    "weight": 1528
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "AWP",
    "weight": 1503
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "CHICAGO",
    "weight": 1480
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "DETROIT",
    "weight": 1262
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "DET",
    "weight": 1240
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "SEA",
    "weight": 1162
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "MSP",
    "weight": 1046
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "ATL",
    "weight": 1029
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "CA",
    "weight": 984
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "NYC",
    "weight": 957
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "ORL",
    "weight": 905
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "IL",
    "weight": 890
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "DALLAS-FT WORTH",
    "weight": 888
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "WASHINGTON",
    "weight": 887
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "FL",
    "weight": 856
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "ST LOUIS",
    "weight": 847
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "HAR",
    "weight": 846
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "PA",
    "weight": 804
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "ATLANTA",
    "weight": 780
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "HOUSTON",
    "weight": 765
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "ANE",
    "weight": 763
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "OH",
    "weight": 749
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "SEATTLE",
    "weight": 749
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "KANSAS CITY",
    "weight": 713
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "TWIN CITIES",
    "weight": 699
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "DEN",
    "weight": 679
  },
  {
    "fieldName": "cntl_twr",
    "fieldPath": "cntl_twr",
    "fieldType": "string",
    "fieldValue": "Y",
    "weight": 669
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "DCA",
    "weight": 667
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "IN",
    "weight": 643
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "CINCINNATI",
    "weight": 624
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "BIS",
    "weight": 616
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "AK",
    "weight": 608
  },
  {
    "fieldName": "faa_region",
    "fieldPath": "faa_region",
    "fieldType": "string",
    "fieldValue": "AAL",
    "weight": 608
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "MEMPHIS",
    "weight": 605
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "SFO",
    "weight": 585
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "NY",
    "weight": 576
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "OMAHA",
    "weight": 551
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "WI",
    "weight": 543
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "MO",
    "weight": 537
  },
  {
    "fieldName": "fed_agree",
    "fieldPath": "fed_agree",
    "fieldType": "string",
    "fieldValue": "N",
    "weight": 515
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "MN",
    "weight": 507
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "SAN ANTONIO",
    "weight": 503
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "JAN",
    "weight": 502
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "LA",
    "weight": 500
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "LOS ANGELES",
    "weight": 498
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "MI",
    "weight": 489
  },
  {
    "fieldName": "faa_dist",
    "fieldPath": "faa_dist",
    "fieldType": "string",
    "fieldValue": "MEM",
    "weight": 487
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "WA",
    "weight": 484
  },
  {
    "fieldName": "fac_type",
    "fieldPath": "fac_type",
    "fieldType": "string",
    "fieldValue": "SEAPLANE BASE",
    "weight": 473
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "JACKSONVILLE",
    "weight": 467
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "NEW ORLEANS",
    "weight": 444
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "OK",
    "weight": 443
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "OR",
    "weight": 441
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "GA",
    "weight": 440
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "ND",
    "weight": 436
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "SAN FRANCISCO",
    "weight": 427
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "CO",
    "weight": 425
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "VA",
    "weight": 421
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "GREEN BAY",
    "weight": 418
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "KS",
    "weight": 415
  },
  {
    "fieldName": "state",
    "fieldPath": "state",
    "fieldType": "string",
    "fieldValue": "NC",
    "weight": 400
  },
  {
    "fieldName": "aero_cht",
    "fieldPath": "aero_cht",
    "fieldType": "string",
    "fieldValue": "CHARLOTTE",
    "weight": 380
  }
]
WITH __stage0 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'string'
      WHEN 1 THEN 'string'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'string'
      WHEN 4 THEN 'number'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'string'
      WHEN 7 THEN 'string'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'number'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
      WHEN 14 THEN 'string'
      WHEN 15 THEN 'string'
      WHEN 16 THEN 'string'
      WHEN 17 THEN 'string'
      WHEN 18 THEN 'number'
      WHEN 19 THEN 'string'
      WHEN 20 THEN 'number'
      WHEN 21 THEN 'number'
      WHEN 22 THEN 'string'
      WHEN 23 THEN 'string'
      WHEN 24 THEN 'string'
      WHEN 25 THEN 'string'
      WHEN 26 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 0 THEN base."act_date"
      WHEN 1 THEN base."aero_cht"
      WHEN 2 THEN base."c_ldg_rts"
      WHEN 3 THEN base."cbd_dir"
      WHEN 5 THEN base."cert"
      WHEN 6 THEN base."city"
      WHEN 7 THEN base."cntl_twr"
      WHEN 8 THEN base."code"
      WHEN 9 THEN base."county"
      WHEN 10 THEN base."cust_intl"
      WHEN 12 THEN base."faa_dist"
      WHEN 13 THEN base."faa_region"
      WHEN 14 THEN base."fac_type"
      WHEN 15 THEN base."fac_use"
      WHEN 16 THEN base."fed_agree"
      WHEN 17 THEN base."full_name"
      WHEN 19 THEN base."joint_use"
      WHEN 22 THEN base."major"
      WHEN 23 THEN base."mil_rts"
      WHEN 24 THEN base."own_type"
      WHEN 25 THEN base."site_number"
      WHEN 26 THEN base."state"
    END as "fieldValue",
   COUNT(*) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 4 THEN MIN(CAST(base."cbd_dist" as VARCHAR)) || ' to ' || CAST(MAX(base."cbd_dist") as VARCHAR)
      WHEN 11 THEN MIN(CAST(base."elevation" as VARCHAR)) || ' to ' || CAST(MAX(base."elevation") as VARCHAR)
      WHEN 18 THEN MIN(CAST(base."id" as VARCHAR)) || ' to ' || CAST(MAX(base."id") as VARCHAR)
      WHEN 20 THEN MIN(CAST(base."latitude" as VARCHAR)) || ' to ' || CAST(MAX(base."latitude") as VARCHAR)
      WHEN 21 THEN MIN(CAST(base."longitude" as VARCHAR)) || ' to ' || CAST(MAX(base."longitude") as VARCHAR)
    END as "fieldRange"
  FROM '../data/airports.parquet' as base
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,27,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
, __stage1 AS (
  SELECT
    "fieldName",
    "fieldPath",
    "fieldType",
    COALESCE("fieldValue", "fieldRange") as "fieldValue",
    weight
  FROM __stage0
)
SELECT 
   base."fieldName" as "fieldName",
   base."fieldPath" as "fieldPath",
   base."fieldType" as "fieldType",
   base."fieldValue" as "fieldValue",
   base."weight" as "weight"
FROM __stage1 as base
WHERE base."fieldType"='string'
ORDER BY 5 desc NULLS LAST

Index For Filtering User Interfaces

Indexes can be used find the best way to filter a dataset. For example supposed we'd like to find 'SANTA CRUZ' in the dataset. Upon approaching the dataset, but we don't which column might contain it. In a UI you might imagine that you type 'SANTA' and let have suggestons for values that might be appropriate. In the results we can see that top value, 'SANTA ROSA', appears as county on 26 rows in the table. We can also see that 'SANTA CRUZ' is both a city and a county..

document
run: duckdb.table('../data/airports.parquet') -> {
  index: *
} -> {
  where: fieldValue ~ r'SANTA'
  select: *
  order_by: weight desc
  limit: 15
}
QUERY RESULTS
fieldNamefieldPathfieldTypefieldValueweight
countycountystringSANTA ROSA26
countycountystringSANTA BARBARA22
countycountystringSANTA CRUZ10
countycountystringSANTA CLARA10
countycountystringSANTA FE9
citycitystringSANTA FE6
citycitystringSANTA ANA6
citycitystringSANTA BARBARA5
citycitystringSANTA ROSA4
citycitystringSANTA MARIA3
citycitystringSANTA YNEZ3
citycitystringSANTA ELENA2
citycitystringSANTA YSABEL2
citycitystringRANCHO SANTA MARGARITA2
citycitystringSANTA CRUZ2
[
  {
    "fieldName": "county",
    "fieldPath": "county",
    "fieldType": "string",
    "fieldValue": "SANTA ROSA",
    "weight": 26
  },
  {
    "fieldName": "county",
    "fieldPath": "county",
    "fieldType": "string",
    "fieldValue": "SANTA BARBARA",
    "weight": 22
  },
  {
    "fieldName": "county",
    "fieldPath": "county",
    "fieldType": "string",
    "fieldValue": "SANTA CRUZ",
    "weight": 10
  },
  {
    "fieldName": "county",
    "fieldPath": "county",
    "fieldType": "string",
    "fieldValue": "SANTA CLARA",
    "weight": 10
  },
  {
    "fieldName": "county",
    "fieldPath": "county",
    "fieldType": "string",
    "fieldValue": "SANTA FE",
    "weight": 9
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA FE",
    "weight": 6
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA ANA",
    "weight": 6
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA BARBARA",
    "weight": 5
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA ROSA",
    "weight": 4
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA MARIA",
    "weight": 3
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA YNEZ",
    "weight": 3
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA ELENA",
    "weight": 2
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA YSABEL",
    "weight": 2
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "RANCHO SANTA MARGARITA",
    "weight": 2
  },
  {
    "fieldName": "city",
    "fieldPath": "city",
    "fieldType": "string",
    "fieldValue": "SANTA CRUZ",
    "weight": 2
  }
]
WITH __stage0 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'string'
      WHEN 1 THEN 'string'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'string'
      WHEN 4 THEN 'number'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'string'
      WHEN 7 THEN 'string'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'number'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
      WHEN 14 THEN 'string'
      WHEN 15 THEN 'string'
      WHEN 16 THEN 'string'
      WHEN 17 THEN 'string'
      WHEN 18 THEN 'number'
      WHEN 19 THEN 'string'
      WHEN 20 THEN 'number'
      WHEN 21 THEN 'number'
      WHEN 22 THEN 'string'
      WHEN 23 THEN 'string'
      WHEN 24 THEN 'string'
      WHEN 25 THEN 'string'
      WHEN 26 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 0 THEN base."act_date"
      WHEN 1 THEN base."aero_cht"
      WHEN 2 THEN base."c_ldg_rts"
      WHEN 3 THEN base."cbd_dir"
      WHEN 5 THEN base."cert"
      WHEN 6 THEN base."city"
      WHEN 7 THEN base."cntl_twr"
      WHEN 8 THEN base."code"
      WHEN 9 THEN base."county"
      WHEN 10 THEN base."cust_intl"
      WHEN 12 THEN base."faa_dist"
      WHEN 13 THEN base."faa_region"
      WHEN 14 THEN base."fac_type"
      WHEN 15 THEN base."fac_use"
      WHEN 16 THEN base."fed_agree"
      WHEN 17 THEN base."full_name"
      WHEN 19 THEN base."joint_use"
      WHEN 22 THEN base."major"
      WHEN 23 THEN base."mil_rts"
      WHEN 24 THEN base."own_type"
      WHEN 25 THEN base."site_number"
      WHEN 26 THEN base."state"
    END as "fieldValue",
   COUNT(*) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 4 THEN MIN(CAST(base."cbd_dist" as VARCHAR)) || ' to ' || CAST(MAX(base."cbd_dist") as VARCHAR)
      WHEN 11 THEN MIN(CAST(base."elevation" as VARCHAR)) || ' to ' || CAST(MAX(base."elevation") as VARCHAR)
      WHEN 18 THEN MIN(CAST(base."id" as VARCHAR)) || ' to ' || CAST(MAX(base."id") as VARCHAR)
      WHEN 20 THEN MIN(CAST(base."latitude" as VARCHAR)) || ' to ' || CAST(MAX(base."latitude") as VARCHAR)
      WHEN 21 THEN MIN(CAST(base."longitude" as VARCHAR)) || ' to ' || CAST(MAX(base."longitude") as VARCHAR)
    END as "fieldRange"
  FROM '../data/airports.parquet' as base
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,27,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
, __stage1 AS (
  SELECT
    "fieldName",
    "fieldPath",
    "fieldType",
    COALESCE("fieldValue", "fieldRange") as "fieldValue",
    weight
  FROM __stage0
)
SELECT 
   base."fieldName" as "fieldName",
   base."fieldPath" as "fieldPath",
   base."fieldType" as "fieldType",
   base."fieldValue" as "fieldValue",
   base."weight" as "weight"
FROM __stage1 as base
WHERE REGEXP_MATCHES(base."fieldValue", 'SANTA')
ORDER BY 5 desc NULLS LAST
LIMIT 15

We can then write a simple query to show the rows. It turns out that 'SANTA CRUZ' is a county in both California and Arizona.

document
run: duckdb.table('../data/airports.parquet') -> {
  where: county ~ 'SANTA CRUZ'
  select: *
}
QUERY RESULTS
act_​dateaero_​chtc_​ldg_​rtscbd_​dircbd_​distcertcitycntl_​twrcodecountycust_​intlelevationfaa_​distfaa_​regionfac_​typefac_​usefed_​agreefull_​nameidjoint_​uselatitudelongitudemajormil_​rtsown_​typesite_​numberstate
10/1987PHOENIXE1TUBACN2AZ8SANTA CRUZ3,200NONEAWPULTRALIGHTPRTUBAC ULTRALIGHT FLIGHTPARK1,44431.61-111.03NPR00811.*UAZ
PHOENIXNNE7NOGALESNOLSSANTA CRUZY3,955NONEAWPAIRPORTPUNGYNOGALES INTL1,312N31.41-110.84NYPU00739.*AAZ
LOS ANGELES0SAN NICOLAS ISLANDYNSISANTA CRUZ504NONEAWPAIRPORTPRSAN NICOLAS ISLAND NOLF2,28733.23-119.45NYMN02220.*ACA
07/1986SAN FRANCISCONW8SANTA CRUZNCL77SANTA CRUZ2,020SFOAWPAIRPORTPRBONNY DOON VILLAGE2,30737.07-122.12NPR02241.1*ACA
SAN FRANCISCONE3SANTA CRUZNCA37SANTA CRUZ115SFOAWPHELIPORTPRDOMINICAN SANTA CRUZ HOSPITAL2,30836.99-121.98NPR02241.12*HCA
SAN FRANCISCONW6DAVENPORTN6Q6SANTA CRUZ125SFOAWPAIRPORTPRLAS TRANCAS1,693N37.08-122.27NNPR01486.9*ACA
SAN FRANCISCONW5WATSONVILLENCA65SANTA CRUZ480SFOAWPHELIPORTPRALTA VISTA2,441N36.97-121.86NNPR02429.1*HCA
09/1987SAN FRANCISCOE0WATSONVILLENCL99SANTA CRUZ111SFOAWPHELIPORTPRWATSONVILLE COMMUNITY HOSPITAL2,44236.93-121.77NPU02429.11*HCA
SAN FRANCISCOW4WATSONVILLENCA66SANTA CRUZ70SFOAWPAIRPORTPRMONTEREY BAY ACADEMY2,443N36.9-121.84NNPR02429.2*ACA
SAN FRANCISCONNW3WATSONVILLENWVISANTA CRUZN160SFOAWPAIRPORTPUNGPRYWATSONVILLE MUNI2,440N36.93-121.78NYPU02429.*ACA
[
  {
    "act_date": "10/1987",
    "aero_cht": "PHOENIX",
    "c_ldg_rts": null,
    "cbd_dir": "E",
    "cbd_dist": 1,
    "cert": null,
    "city": "TUBAC",
    "cntl_twr": "N",
    "code": "2AZ8",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 3200,
    "faa_dist": "NONE",
    "faa_region": "AWP",
    "fac_type": "ULTRALIGHT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "TUBAC ULTRALIGHT FLIGHTPARK",
    "id": 1444,
    "joint_use": null,
    "latitude": 31.61,
    "longitude": -111.03,
    "major": "N",
    "mil_rts": null,
    "own_type": "PR",
    "site_number": "00811.*U",
    "state": "AZ"
  },
  {
    "act_date": null,
    "aero_cht": "PHOENIX",
    "c_ldg_rts": "N",
    "cbd_dir": "NE",
    "cbd_dist": 7,
    "cert": null,
    "city": "NOGALES",
    "cntl_twr": "N",
    "code": "OLS",
    "county": "SANTA CRUZ",
    "cust_intl": "Y",
    "elevation": 3955,
    "faa_dist": "NONE",
    "faa_region": "AWP",
    "fac_type": "AIRPORT",
    "fac_use": "PU",
    "fed_agree": "NGY",
    "full_name": "NOGALES INTL",
    "id": 1312,
    "joint_use": "N",
    "latitude": 31.41,
    "longitude": -110.84,
    "major": "N",
    "mil_rts": "Y",
    "own_type": "PU",
    "site_number": "00739.*A",
    "state": "AZ"
  },
  {
    "act_date": null,
    "aero_cht": "LOS ANGELES",
    "c_ldg_rts": null,
    "cbd_dir": null,
    "cbd_dist": 0,
    "cert": null,
    "city": "SAN NICOLAS ISLAND",
    "cntl_twr": "Y",
    "code": "NSI",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 504,
    "faa_dist": "NONE",
    "faa_region": "AWP",
    "fac_type": "AIRPORT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "SAN NICOLAS ISLAND NOLF",
    "id": 2287,
    "joint_use": null,
    "latitude": 33.23,
    "longitude": -119.45,
    "major": "N",
    "mil_rts": "Y",
    "own_type": "MN",
    "site_number": "02220.*A",
    "state": "CA"
  },
  {
    "act_date": "07/1986",
    "aero_cht": "SAN FRANCISCO",
    "c_ldg_rts": null,
    "cbd_dir": "NW",
    "cbd_dist": 8,
    "cert": null,
    "city": "SANTA CRUZ",
    "cntl_twr": "N",
    "code": "CL77",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 2020,
    "faa_dist": "SFO",
    "faa_region": "AWP",
    "fac_type": "AIRPORT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "BONNY DOON VILLAGE",
    "id": 2307,
    "joint_use": null,
    "latitude": 37.07,
    "longitude": -122.12,
    "major": "N",
    "mil_rts": null,
    "own_type": "PR",
    "site_number": "02241.1*A",
    "state": "CA"
  },
  {
    "act_date": null,
    "aero_cht": "SAN FRANCISCO",
    "c_ldg_rts": null,
    "cbd_dir": "NE",
    "cbd_dist": 3,
    "cert": null,
    "city": "SANTA CRUZ",
    "cntl_twr": "N",
    "code": "CA37",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 115,
    "faa_dist": "SFO",
    "faa_region": "AWP",
    "fac_type": "HELIPORT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "DOMINICAN SANTA CRUZ HOSPITAL",
    "id": 2308,
    "joint_use": null,
    "latitude": 36.99,
    "longitude": -121.98,
    "major": "N",
    "mil_rts": null,
    "own_type": "PR",
    "site_number": "02241.12*H",
    "state": "CA"
  },
  {
    "act_date": null,
    "aero_cht": "SAN FRANCISCO",
    "c_ldg_rts": null,
    "cbd_dir": "NW",
    "cbd_dist": 6,
    "cert": null,
    "city": "DAVENPORT",
    "cntl_twr": "N",
    "code": "6Q6",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 125,
    "faa_dist": "SFO",
    "faa_region": "AWP",
    "fac_type": "AIRPORT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "LAS TRANCAS",
    "id": 1693,
    "joint_use": "N",
    "latitude": 37.08,
    "longitude": -122.27,
    "major": "N",
    "mil_rts": "N",
    "own_type": "PR",
    "site_number": "01486.9*A",
    "state": "CA"
  },
  {
    "act_date": null,
    "aero_cht": "SAN FRANCISCO",
    "c_ldg_rts": null,
    "cbd_dir": "NW",
    "cbd_dist": 5,
    "cert": null,
    "city": "WATSONVILLE",
    "cntl_twr": "N",
    "code": "CA65",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 480,
    "faa_dist": "SFO",
    "faa_region": "AWP",
    "fac_type": "HELIPORT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "ALTA VISTA",
    "id": 2441,
    "joint_use": "N",
    "latitude": 36.97,
    "longitude": -121.86,
    "major": "N",
    "mil_rts": "N",
    "own_type": "PR",
    "site_number": "02429.1*H",
    "state": "CA"
  },
  {
    "act_date": "09/1987",
    "aero_cht": "SAN FRANCISCO",
    "c_ldg_rts": null,
    "cbd_dir": "E",
    "cbd_dist": 0,
    "cert": null,
    "city": "WATSONVILLE",
    "cntl_twr": "N",
    "code": "CL99",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 111,
    "faa_dist": "SFO",
    "faa_region": "AWP",
    "fac_type": "HELIPORT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "WATSONVILLE COMMUNITY HOSPITAL",
    "id": 2442,
    "joint_use": null,
    "latitude": 36.93,
    "longitude": -121.77,
    "major": "N",
    "mil_rts": null,
    "own_type": "PU",
    "site_number": "02429.11*H",
    "state": "CA"
  },
  {
    "act_date": null,
    "aero_cht": "SAN FRANCISCO",
    "c_ldg_rts": null,
    "cbd_dir": "W",
    "cbd_dist": 4,
    "cert": null,
    "city": "WATSONVILLE",
    "cntl_twr": "N",
    "code": "CA66",
    "county": "SANTA CRUZ",
    "cust_intl": null,
    "elevation": 70,
    "faa_dist": "SFO",
    "faa_region": "AWP",
    "fac_type": "AIRPORT",
    "fac_use": "PR",
    "fed_agree": null,
    "full_name": "MONTEREY BAY ACADEMY",
    "id": 2443,
    "joint_use": "N",
    "latitude": 36.9,
    "longitude": -121.84,
    "major": "N",
    "mil_rts": "N",
    "own_type": "PR",
    "site_number": "02429.2*A",
    "state": "CA"
  },
  {
    "act_date": null,
    "aero_cht": "SAN FRANCISCO",
    "c_ldg_rts": "N",
    "cbd_dir": "NW",
    "cbd_dist": 3,
    "cert": null,
    "city": "WATSONVILLE",
    "cntl_twr": "N",
    "code": "WVI",
    "county": "SANTA CRUZ",
    "cust_intl": "N",
    "elevation": 160,
    "faa_dist": "SFO",
    "faa_region": "AWP",
    "fac_type": "AIRPORT",
    "fac_use": "PU",
    "fed_agree": "NGPRY",
    "full_name": "WATSONVILLE MUNI",
    "id": 2440,
    "joint_use": "N",
    "latitude": 36.93,
    "longitude": -121.78,
    "major": "N",
    "mil_rts": "Y",
    "own_type": "PU",
    "site_number": "02429.*A",
    "state": "CA"
  }
]
SELECT 
   base."act_date" as "act_date",
   base."aero_cht" as "aero_cht",
   base."c_ldg_rts" as "c_ldg_rts",
   base."cbd_dir" as "cbd_dir",
   base."cbd_dist" as "cbd_dist",
   base."cert" as "cert",
   base."city" as "city",
   base."cntl_twr" as "cntl_twr",
   base."code" as "code",
   base."county" as "county",
   base."cust_intl" as "cust_intl",
   base."elevation" as "elevation",
   base."faa_dist" as "faa_dist",
   base."faa_region" as "faa_region",
   base."fac_type" as "fac_type",
   base."fac_use" as "fac_use",
   base."fed_agree" as "fed_agree",
   base."full_name" as "full_name",
   base."id" as "id",
   base."joint_use" as "joint_use",
   base."latitude" as "latitude",
   base."longitude" as "longitude",
   base."major" as "major",
   base."mil_rts" as "mil_rts",
   base."own_type" as "own_type",
   base."site_number" as "site_number",
   base."state" as "state"
FROM '../data/airports.parquet' as base
WHERE base."county" LIKE 'SANTA CRUZ'

Indexing to show top values for each dimension

It is often difficult to approach a new dataset. The index operator provides an intersting way to quickly gain an understanding of the dataset. By piping the results of an index another stage, we can quickly see all the interesting values for each of the interesting dimesions. Again, the weight shows the number of rows for that particular dimension/value.

document
run: duckdb.table('../data/airports.parquet') -> {
  index: *
} -> {
  group_by: fieldName
  nest: values is {
    group_by: fieldValue, weight
    order_by: weight desc
    limit: 10
  }
  order_by: fieldName
}
QUERY RESULTS
fieldNamevalues
act_date
fieldValueweight
12,040
04/1993145
02/1987129
03/1993127
11/1990122
11/1986119
02/1982118
08/1988115
11/1988113
03/1988113
aero_cht
fieldValueweight
NEW YORK1,581
CHICAGO1,480
DETROIT1,262
DALLAS-FT WORTH888
WASHINGTON887
ST LOUIS847
ATLANTA780
HOUSTON765
SEATTLE749
KANSAS CITY713
c_ldg_rts
fieldValueweight
15,145
N4,365
Y283
cbd_dir
fieldValueweight
N3,694
NW2,438
SW2,427
NE2,393
SE2,281
S2,155
E2,127
W2,065
119
SSW20
cbd_dist
fieldValueweight
0 to 7319,793
cert
fieldValueweight
19,142
AS 05/197394
CS 05/197384
BS 05/197381
LU 05/197337
LU 08/199033
DS 05/197326
AU 05/197325
ES 05/197315
LU 11/19749
city
fieldValueweight
HOUSTON108
LOS ANGELES60
COLUMBUS47
SPRINGFIELD45
JACKSON42
GREENVILLE38
WASHINGTON38
PHOENIX37
CLINTON37
PHILADELPHIA35
cntl_twr
fieldValueweight
N19,124
Y669
code
fieldValueweight
ROR1
34AK1
CJX1
AKA1
43AK1
6K81
10AK1
EXI1
5Z21
MLL1
county
fieldValueweight
WASHINGTON214
JEFFERSON199
LOS ANGELES176
MONTGOMERY154
FRANKLIN140
JACKSON140
HARRIS137
MARION127
ORANGE125
MARICOPA117
cust_intl
fieldValueweight
15,145
N4,575
Y73
elevation
fieldValueweight
-1 to 1244219,793
faa_dist
fieldValueweight
NONE7,085
CHI1,528
DET1,240
SEA1,162
MSP1,046
ATL1,029
NYC957
ORL905
HAR846
DEN679
faa_region
fieldValueweight
AGL4,437
ASW3,268
ASO2,924
AEA2,586
ANM2,102
ACE1,579
AWP1,503
ANE763
AAL608
23
fac_type
fieldValueweight
AIRPORT13,925
HELIPORT5,135
SEAPLANE BASE473
ULTRALIGHT125
STOLPORT86
GLIDERPORT37
BALLOONPORT12
fac_use
fieldValueweight
PR14,428
PU5,365
fed_agree
fieldValueweight
16,252
NGY1,682
N515
NGY3219
NGPY171
NY1123
N197
196
NGSY87
NGPY384
full_name
fieldValueweight
MEMORIAL HOSPITAL21
SMITH14
JOHNSON13
ST MARY'S HOSPITAL11
MILLER10
HILLTOP10
DAVIS FIELD10
WILSON9
TAYLOR9
DAVIS9
id
fieldValueweight
1 to 1979319,793
joint_use
fieldValueweight
14,804
N4,779
Y210
latitude
fieldValueweight
-14.18 to 71.2819,793
longitude
fieldValueweight
-100.0 to 174.1119,793
major
fieldValueweight
N19,523
Y270
mil_rts
fieldValueweight
14,716
Y2,958
N2,119
own_type
fieldValueweight
PR14,306
PU5,174
MR128
MA107
MN78
site_number
fieldValueweight
51518.6*A1
51541.*A1
50410.13*C1
50720.04*A1
50080.5*A1
50870.21*A1
50530.*A1
50178.01*A1
50427.61*A1
50425.2*H1
state
fieldValueweight
TX1,845
CA984
IL890
FL856
PA804
OH749
IN643
AK608
NY576
WI543
fieldValueweight
19,793
[
  {
    "fieldName": "act_date",
    "values": [
      {
        "fieldValue": null,
        "weight": 12040
      },
      {
        "fieldValue": "04/1993",
        "weight": 145
      },
      {
        "fieldValue": "02/1987",
        "weight": 129
      },
      {
        "fieldValue": "03/1993",
        "weight": 127
      },
      {
        "fieldValue": "11/1990",
        "weight": 122
      },
      {
        "fieldValue": "11/1986",
        "weight": 119
      },
      {
        "fieldValue": "02/1982",
        "weight": 118
      },
      {
        "fieldValue": "08/1988",
        "weight": 115
      },
      {
        "fieldValue": "11/1988",
        "weight": 113
      },
      {
        "fieldValue": "03/1988",
        "weight": 113
      }
    ]
  },
  {
    "fieldName": "aero_cht",
    "values": [
      {
        "fieldValue": "NEW YORK",
        "weight": 1581
      },
      {
        "fieldValue": "CHICAGO",
        "weight": 1480
      },
      {
        "fieldValue": "DETROIT",
        "weight": 1262
      },
      {
        "fieldValue": "DALLAS-FT WORTH",
        "weight": 888
      },
      {
        "fieldValue": "WASHINGTON",
        "weight": 887
      },
      {
        "fieldValue": "ST LOUIS",
        "weight": 847
      },
      {
        "fieldValue": "ATLANTA",
        "weight": 780
      },
      {
        "fieldValue": "HOUSTON",
        "weight": 765
      },
      {
        "fieldValue": "SEATTLE",
        "weight": 749
      },
      {
        "fieldValue": "KANSAS CITY",
        "weight": 713
      }
    ]
  },
  {
    "fieldName": "c_ldg_rts",
    "values": [
      {
        "fieldValue": null,
        "weight": 15145
      },
      {
        "fieldValue": "N",
        "weight": 4365
      },
      {
        "fieldValue": "Y",
        "weight": 283
      }
    ]
  },
  {
    "fieldName": "cbd_dir",
    "values": [
      {
        "fieldValue": "N",
        "weight": 3694
      },
      {
        "fieldValue": "NW",
        "weight": 2438
      },
      {
        "fieldValue": "SW",
        "weight": 2427
      },
      {
        "fieldValue": "NE",
        "weight": 2393
      },
      {
        "fieldValue": "SE",
        "weight": 2281
      },
      {
        "fieldValue": "S",
        "weight": 2155
      },
      {
        "fieldValue": "E",
        "weight": 2127
      },
      {
        "fieldValue": "W",
        "weight": 2065
      },
      {
        "fieldValue": null,
        "weight": 119
      },
      {
        "fieldValue": "SSW",
        "weight": 20
      }
    ]
  },
  {
    "fieldName": "cbd_dist",
    "values": [
      {
        "fieldValue": "0 to 73",
        "weight": 19793
      }
    ]
  },
  {
    "fieldName": "cert",
    "values": [
      {
        "fieldValue": null,
        "weight": 19142
      },
      {
        "fieldValue": "AS 05/1973",
        "weight": 94
      },
      {
        "fieldValue": "CS 05/1973",
        "weight": 84
      },
      {
        "fieldValue": "BS 05/1973",
        "weight": 81
      },
      {
        "fieldValue": "LU 05/1973",
        "weight": 37
      },
      {
        "fieldValue": "LU 08/1990",
        "weight": 33
      },
      {
        "fieldValue": "DS 05/1973",
        "weight": 26
      },
      {
        "fieldValue": "AU 05/1973",
        "weight": 25
      },
      {
        "fieldValue": "ES 05/1973",
        "weight": 15
      },
      {
        "fieldValue": "LU 11/1974",
        "weight": 9
      }
    ]
  },
  {
    "fieldName": "city",
    "values": [
      {
        "fieldValue": "HOUSTON",
        "weight": 108
      },
      {
        "fieldValue": "LOS ANGELES",
        "weight": 60
      },
      {
        "fieldValue": "COLUMBUS",
        "weight": 47
      },
      {
        "fieldValue": "SPRINGFIELD",
        "weight": 45
      },
      {
        "fieldValue": "JACKSON",
        "weight": 42
      },
      {
        "fieldValue": "GREENVILLE",
        "weight": 38
      },
      {
        "fieldValue": "WASHINGTON",
        "weight": 38
      },
      {
        "fieldValue": "PHOENIX",
        "weight": 37
      },
      {
        "fieldValue": "CLINTON",
        "weight": 37
      },
      {
        "fieldValue": "PHILADELPHIA",
        "weight": 35
      }
    ]
  },
  {
    "fieldName": "cntl_twr",
    "values": [
      {
        "fieldValue": "N",
        "weight": 19124
      },
      {
        "fieldValue": "Y",
        "weight": 669
      }
    ]
  },
  {
    "fieldName": "code",
    "values": [
      {
        "fieldValue": "ROR",
        "weight": 1
      },
      {
        "fieldValue": "34AK",
        "weight": 1
      },
      {
        "fieldValue": "CJX",
        "weight": 1
      },
      {
        "fieldValue": "AKA",
        "weight": 1
      },
      {
        "fieldValue": "43AK",
        "weight": 1
      },
      {
        "fieldValue": "6K8",
        "weight": 1
      },
      {
        "fieldValue": "10AK",
        "weight": 1
      },
      {
        "fieldValue": "EXI",
        "weight": 1
      },
      {
        "fieldValue": "5Z2",
        "weight": 1
      },
      {
        "fieldValue": "MLL",
        "weight": 1
      }
    ]
  },
  {
    "fieldName": "county",
    "values": [
      {
        "fieldValue": "WASHINGTON",
        "weight": 214
      },
      {
        "fieldValue": "JEFFERSON",
        "weight": 199
      },
      {
        "fieldValue": "LOS ANGELES",
        "weight": 176
      },
      {
        "fieldValue": "MONTGOMERY",
        "weight": 154
      },
      {
        "fieldValue": "FRANKLIN",
        "weight": 140
      },
      {
        "fieldValue": "JACKSON",
        "weight": 140
      },
      {
        "fieldValue": "HARRIS",
        "weight": 137
      },
      {
        "fieldValue": "MARION",
        "weight": 127
      },
      {
        "fieldValue": "ORANGE",
        "weight": 125
      },
      {
        "fieldValue": "MARICOPA",
        "weight": 117
      }
    ]
  },
  {
    "fieldName": "cust_intl",
    "values": [
      {
        "fieldValue": null,
        "weight": 15145
      },
      {
        "fieldValue": "N",
        "weight": 4575
      },
      {
        "fieldValue": "Y",
        "weight": 73
      }
    ]
  },
  {
    "fieldName": "elevation",
    "values": [
      {
        "fieldValue": "-1 to 12442",
        "weight": 19793
      }
    ]
  },
  {
    "fieldName": "faa_dist",
    "values": [
      {
        "fieldValue": "NONE",
        "weight": 7085
      },
      {
        "fieldValue": "CHI",
        "weight": 1528
      },
      {
        "fieldValue": "DET",
        "weight": 1240
      },
      {
        "fieldValue": "SEA",
        "weight": 1162
      },
      {
        "fieldValue": "MSP",
        "weight": 1046
      },
      {
        "fieldValue": "ATL",
        "weight": 1029
      },
      {
        "fieldValue": "NYC",
        "weight": 957
      },
      {
        "fieldValue": "ORL",
        "weight": 905
      },
      {
        "fieldValue": "HAR",
        "weight": 846
      },
      {
        "fieldValue": "DEN",
        "weight": 679
      }
    ]
  },
  {
    "fieldName": "faa_region",
    "values": [
      {
        "fieldValue": "AGL",
        "weight": 4437
      },
      {
        "fieldValue": "ASW",
        "weight": 3268
      },
      {
        "fieldValue": "ASO",
        "weight": 2924
      },
      {
        "fieldValue": "AEA",
        "weight": 2586
      },
      {
        "fieldValue": "ANM",
        "weight": 2102
      },
      {
        "fieldValue": "ACE",
        "weight": 1579
      },
      {
        "fieldValue": "AWP",
        "weight": 1503
      },
      {
        "fieldValue": "ANE",
        "weight": 763
      },
      {
        "fieldValue": "AAL",
        "weight": 608
      },
      {
        "fieldValue": null,
        "weight": 23
      }
    ]
  },
  {
    "fieldName": "fac_type",
    "values": [
      {
        "fieldValue": "AIRPORT",
        "weight": 13925
      },
      {
        "fieldValue": "HELIPORT",
        "weight": 5135
      },
      {
        "fieldValue": "SEAPLANE BASE",
        "weight": 473
      },
      {
        "fieldValue": "ULTRALIGHT",
        "weight": 125
      },
      {
        "fieldValue": "STOLPORT",
        "weight": 86
      },
      {
        "fieldValue": "GLIDERPORT",
        "weight": 37
      },
      {
        "fieldValue": "BALLOONPORT",
        "weight": 12
      }
    ]
  },
  {
    "fieldName": "fac_use",
    "values": [
      {
        "fieldValue": "PR",
        "weight": 14428
      },
      {
        "fieldValue": "PU",
        "weight": 5365
      }
    ]
  },
  {
    "fieldName": "fed_agree",
    "values": [
      {
        "fieldValue": null,
        "weight": 16252
      },
      {
        "fieldValue": "NGY",
        "weight": 1682
      },
      {
        "fieldValue": "N",
        "weight": 515
      },
      {
        "fieldValue": "NGY3",
        "weight": 219
      },
      {
        "fieldValue": "NGPY",
        "weight": 171
      },
      {
        "fieldValue": "NY1",
        "weight": 123
      },
      {
        "fieldValue": "N1",
        "weight": 97
      },
      {
        "fieldValue": "1",
        "weight": 96
      },
      {
        "fieldValue": "NGSY",
        "weight": 87
      },
      {
        "fieldValue": "NGPY3",
        "weight": 84
      }
    ]
  },
  {
    "fieldName": "full_name",
    "values": [
      {
        "fieldValue": "MEMORIAL HOSPITAL",
        "weight": 21
      },
      {
        "fieldValue": "SMITH",
        "weight": 14
      },
      {
        "fieldValue": "JOHNSON",
        "weight": 13
      },
      {
        "fieldValue": "ST MARY'S HOSPITAL",
        "weight": 11
      },
      {
        "fieldValue": "MILLER",
        "weight": 10
      },
      {
        "fieldValue": "HILLTOP",
        "weight": 10
      },
      {
        "fieldValue": "DAVIS FIELD",
        "weight": 10
      },
      {
        "fieldValue": "WILSON",
        "weight": 9
      },
      {
        "fieldValue": "TAYLOR",
        "weight": 9
      },
      {
        "fieldValue": "DAVIS",
        "weight": 9
      }
    ]
  },
  {
    "fieldName": "id",
    "values": [
      {
        "fieldValue": "1 to 19793",
        "weight": 19793
      }
    ]
  },
  {
    "fieldName": "joint_use",
    "values": [
      {
        "fieldValue": null,
        "weight": 14804
      },
      {
        "fieldValue": "N",
        "weight": 4779
      },
      {
        "fieldValue": "Y",
        "weight": 210
      }
    ]
  },
  {
    "fieldName": "latitude",
    "values": [
      {
        "fieldValue": "-14.18 to 71.28",
        "weight": 19793
      }
    ]
  },
  {
    "fieldName": "longitude",
    "values": [
      {
        "fieldValue": "-100.0 to 174.11",
        "weight": 19793
      }
    ]
  },
  {
    "fieldName": "major",
    "values": [
      {
        "fieldValue": "N",
        "weight": 19523
      },
      {
        "fieldValue": "Y",
        "weight": 270
      }
    ]
  },
  {
    "fieldName": "mil_rts",
    "values": [
      {
        "fieldValue": null,
        "weight": 14716
      },
      {
        "fieldValue": "Y",
        "weight": 2958
      },
      {
        "fieldValue": "N",
        "weight": 2119
      }
    ]
  },
  {
    "fieldName": "own_type",
    "values": [
      {
        "fieldValue": "PR",
        "weight": 14306
      },
      {
        "fieldValue": "PU",
        "weight": 5174
      },
      {
        "fieldValue": "MR",
        "weight": 128
      },
      {
        "fieldValue": "MA",
        "weight": 107
      },
      {
        "fieldValue": "MN",
        "weight": 78
      }
    ]
  },
  {
    "fieldName": "site_number",
    "values": [
      {
        "fieldValue": "51518.6*A",
        "weight": 1
      },
      {
        "fieldValue": "51541.*A",
        "weight": 1
      },
      {
        "fieldValue": "50410.13*C",
        "weight": 1
      },
      {
        "fieldValue": "50720.04*A",
        "weight": 1
      },
      {
        "fieldValue": "50080.5*A",
        "weight": 1
      },
      {
        "fieldValue": "50870.21*A",
        "weight": 1
      },
      {
        "fieldValue": "50530.*A",
        "weight": 1
      },
      {
        "fieldValue": "50178.01*A",
        "weight": 1
      },
      {
        "fieldValue": "50427.61*A",
        "weight": 1
      },
      {
        "fieldValue": "50425.2*H",
        "weight": 1
      }
    ]
  },
  {
    "fieldName": "state",
    "values": [
      {
        "fieldValue": "TX",
        "weight": 1845
      },
      {
        "fieldValue": "CA",
        "weight": 984
      },
      {
        "fieldValue": "IL",
        "weight": 890
      },
      {
        "fieldValue": "FL",
        "weight": 856
      },
      {
        "fieldValue": "PA",
        "weight": 804
      },
      {
        "fieldValue": "OH",
        "weight": 749
      },
      {
        "fieldValue": "IN",
        "weight": 643
      },
      {
        "fieldValue": "AK",
        "weight": 608
      },
      {
        "fieldValue": "NY",
        "weight": 576
      },
      {
        "fieldValue": "WI",
        "weight": 543
      }
    ]
  },
  {
    "fieldName": null,
    "values": [
      {
        "fieldValue": null,
        "weight": 19793
      }
    ]
  }
]
WITH __stage0 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'string'
      WHEN 1 THEN 'string'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'string'
      WHEN 4 THEN 'number'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'string'
      WHEN 7 THEN 'string'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'number'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
      WHEN 14 THEN 'string'
      WHEN 15 THEN 'string'
      WHEN 16 THEN 'string'
      WHEN 17 THEN 'string'
      WHEN 18 THEN 'number'
      WHEN 19 THEN 'string'
      WHEN 20 THEN 'number'
      WHEN 21 THEN 'number'
      WHEN 22 THEN 'string'
      WHEN 23 THEN 'string'
      WHEN 24 THEN 'string'
      WHEN 25 THEN 'string'
      WHEN 26 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 0 THEN base."act_date"
      WHEN 1 THEN base."aero_cht"
      WHEN 2 THEN base."c_ldg_rts"
      WHEN 3 THEN base."cbd_dir"
      WHEN 5 THEN base."cert"
      WHEN 6 THEN base."city"
      WHEN 7 THEN base."cntl_twr"
      WHEN 8 THEN base."code"
      WHEN 9 THEN base."county"
      WHEN 10 THEN base."cust_intl"
      WHEN 12 THEN base."faa_dist"
      WHEN 13 THEN base."faa_region"
      WHEN 14 THEN base."fac_type"
      WHEN 15 THEN base."fac_use"
      WHEN 16 THEN base."fed_agree"
      WHEN 17 THEN base."full_name"
      WHEN 19 THEN base."joint_use"
      WHEN 22 THEN base."major"
      WHEN 23 THEN base."mil_rts"
      WHEN 24 THEN base."own_type"
      WHEN 25 THEN base."site_number"
      WHEN 26 THEN base."state"
    END as "fieldValue",
   COUNT(*) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 4 THEN MIN(CAST(base."cbd_dist" as VARCHAR)) || ' to ' || CAST(MAX(base."cbd_dist") as VARCHAR)
      WHEN 11 THEN MIN(CAST(base."elevation" as VARCHAR)) || ' to ' || CAST(MAX(base."elevation") as VARCHAR)
      WHEN 18 THEN MIN(CAST(base."id" as VARCHAR)) || ' to ' || CAST(MAX(base."id") as VARCHAR)
      WHEN 20 THEN MIN(CAST(base."latitude" as VARCHAR)) || ' to ' || CAST(MAX(base."latitude") as VARCHAR)
      WHEN 21 THEN MIN(CAST(base."longitude" as VARCHAR)) || ' to ' || CAST(MAX(base."longitude") as VARCHAR)
    END as "fieldRange"
  FROM '../data/airports.parquet' as base
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,27,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
, __stage1 AS (
  SELECT
    "fieldName",
    "fieldPath",
    "fieldType",
    COALESCE("fieldValue", "fieldRange") as "fieldValue",
    weight
  FROM __stage0
)
, __stage2 AS (
  SELECT
    group_set,
    base."fieldName" as "fieldName__0",
    CASE WHEN group_set=1 THEN
      base."fieldValue"
      END as "fieldValue__1",
    CASE WHEN group_set=1 THEN
      base."weight"
      END as "weight__1"
  FROM __stage1 as base
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,1,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4
)
SELECT
  "fieldName__0" as "fieldName",
  COALESCE(LIST({
    "fieldValue": "fieldValue__1", 
    "weight": "weight__1"}  ORDER BY  "weight__1" desc NULLS LAST) FILTER (WHERE group_set=1)[1:10],[]) as "values"
FROM __stage2
GROUP BY 1
ORDER BY 1 ASC NULLS LAST

Sampling

With large datasets, you can also sample a small subsection using the sample: parameter. Sampled indexes are great at identifing the important low cardinality fields.

document
run: duckdb.table('../data/airports.parquet') -> {
  index: *
  sample: 5000  // sample only 5000 rows
} -> {
  group_by: fieldName
  nest: values is  {
    group_by: fieldValue, weight
    order_by: weight desc
    limit: 10
  }
  order_by: fieldName
}
QUERY RESULTS
fieldNamevalues
act_date
fieldValueweight
3,044
04/199340
02/198736
11/198633
11/199033
11/198932
08/198531
03/199329
08/198829
05/199928
aero_cht
fieldValueweight
NEW YORK379
CHICAGO357
DETROIT353
WASHINGTON231
DALLAS-FT WORTH213
TWIN CITIES206
ST LOUIS204
SEATTLE200
KANSAS CITY194
ATLANTA191
c_ldg_rts
fieldValueweight
3,837
N1,096
Y67
cbd_dir
fieldValueweight
N929
SW643
NW620
NE597
SE592
S540
E538
W486
29
NNE7
cbd_dist
fieldValueweight
0 to 625,000
cert
fieldValueweight
4,839
AS 05/197331
CS 05/197321
BS 05/197318
LU 05/197310
DS 05/19735
AU 05/19734
LU 08/19904
LU 12/19743
LU 12/19922
city
fieldValueweight
HOUSTON28
SALEM15
SPRINGFIELD11
PLYMOUTH10
CLINTON10
ALBANY10
COLUMBUS10
COLUMBIA10
MANSFIELD9
DALLAS9
cntl_twr
fieldValueweight
N4,839
Y161
code
fieldValueweight
PS201
3W91
11AK1
WA941
57WI1
OG221
2AK1
M131
RCX1
2AK41
county
fieldValueweight
WASHINGTON61
FRANKLIN45
MONTGOMERY44
LOS ANGELES42
LINCOLN41
JACKSON37
JEFFERSON36
MARION33
HARRIS30
ADAMS29
cust_intl
fieldValueweight
3,837
N1,149
Y14
elevation
fieldValueweight
-113 to 100855,000
faa_dist
fieldValueweight
NONE1,747
CHI376
DET323
SEA305
ATL276
MSP265
HAR231
NYC231
ORL206
BIS191
faa_region
fieldValueweight
AGL1,158
ASW805
ASO736
AEA664
ANM542
ACE421
AWP335
ANE197
AAL137
5
fac_type
fieldValueweight
AIRPORT3,540
HELIPORT1,274
SEAPLANE BASE115
ULTRALIGHT35
STOLPORT20
GLIDERPORT13
BALLOONPORT3
fac_use
fieldValueweight
PR3,631
PU1,369
fed_agree
fieldValueweight
4,116
NGY406
N119
NGY363
NGPY38
NY135
132
NGSY20
NGPY320
N120
full_name
fieldValueweight
MEMORIAL HOSPITAL6
MERCY HOSPITAL4
DAVIS4
MEDICAL CENTER4
CLARK4
ADAMS4
FLYING W4
FLYING H RANCH3
ST JOSEPH'S HOSPITAL3
RIVERSIDE3
id
fieldValueweight
10001 to 197895,000
joint_use
fieldValueweight
3,733
N1,215
Y52
latitude
fieldValueweight
-14.21 to 70.45,000
longitude
fieldValueweight
-100.0 to 170.885,000
major
fieldValueweight
N4,933
Y67
mil_rts
fieldValueweight
3,714
Y737
N549
own_type
fieldValueweight
PR3,605
PU1,328
MR35
MA20
MN12
site_number
fieldValueweight
14789.2*H1
10703.*A1
19589.04*H1
50320.2*A1
50072.5*A1
22780.5*A1
50215.02*H1
50325.*A1
25928.5*H1
05541.2*A1
state
fieldValueweight
TX455
CA233
PA219
IL218
OH200
FL196
IN160
MO145
LA140
AK137
fieldValueweight
5,000
[
  {
    "fieldName": "act_date",
    "values": [
      {
        "fieldValue": null,
        "weight": 3044
      },
      {
        "fieldValue": "04/1993",
        "weight": 40
      },
      {
        "fieldValue": "02/1987",
        "weight": 36
      },
      {
        "fieldValue": "11/1986",
        "weight": 33
      },
      {
        "fieldValue": "11/1990",
        "weight": 33
      },
      {
        "fieldValue": "11/1989",
        "weight": 32
      },
      {
        "fieldValue": "08/1985",
        "weight": 31
      },
      {
        "fieldValue": "03/1993",
        "weight": 29
      },
      {
        "fieldValue": "08/1988",
        "weight": 29
      },
      {
        "fieldValue": "05/1999",
        "weight": 28
      }
    ]
  },
  {
    "fieldName": "aero_cht",
    "values": [
      {
        "fieldValue": "NEW YORK",
        "weight": 379
      },
      {
        "fieldValue": "CHICAGO",
        "weight": 357
      },
      {
        "fieldValue": "DETROIT",
        "weight": 353
      },
      {
        "fieldValue": "WASHINGTON",
        "weight": 231
      },
      {
        "fieldValue": "DALLAS-FT WORTH",
        "weight": 213
      },
      {
        "fieldValue": "TWIN CITIES",
        "weight": 206
      },
      {
        "fieldValue": "ST LOUIS",
        "weight": 204
      },
      {
        "fieldValue": "SEATTLE",
        "weight": 200
      },
      {
        "fieldValue": "KANSAS CITY",
        "weight": 194
      },
      {
        "fieldValue": "ATLANTA",
        "weight": 191
      }
    ]
  },
  {
    "fieldName": "c_ldg_rts",
    "values": [
      {
        "fieldValue": null,
        "weight": 3837
      },
      {
        "fieldValue": "N",
        "weight": 1096
      },
      {
        "fieldValue": "Y",
        "weight": 67
      }
    ]
  },
  {
    "fieldName": "cbd_dir",
    "values": [
      {
        "fieldValue": "N",
        "weight": 929
      },
      {
        "fieldValue": "SW",
        "weight": 643
      },
      {
        "fieldValue": "NW",
        "weight": 620
      },
      {
        "fieldValue": "NE",
        "weight": 597
      },
      {
        "fieldValue": "SE",
        "weight": 592
      },
      {
        "fieldValue": "S",
        "weight": 540
      },
      {
        "fieldValue": "E",
        "weight": 538
      },
      {
        "fieldValue": "W",
        "weight": 486
      },
      {
        "fieldValue": null,
        "weight": 29
      },
      {
        "fieldValue": "NNE",
        "weight": 7
      }
    ]
  },
  {
    "fieldName": "cbd_dist",
    "values": [
      {
        "fieldValue": "0 to 62",
        "weight": 5000
      }
    ]
  },
  {
    "fieldName": "cert",
    "values": [
      {
        "fieldValue": null,
        "weight": 4839
      },
      {
        "fieldValue": "AS 05/1973",
        "weight": 31
      },
      {
        "fieldValue": "CS 05/1973",
        "weight": 21
      },
      {
        "fieldValue": "BS 05/1973",
        "weight": 18
      },
      {
        "fieldValue": "LU 05/1973",
        "weight": 10
      },
      {
        "fieldValue": "DS 05/1973",
        "weight": 5
      },
      {
        "fieldValue": "AU 05/1973",
        "weight": 4
      },
      {
        "fieldValue": "LU 08/1990",
        "weight": 4
      },
      {
        "fieldValue": "LU 12/1974",
        "weight": 3
      },
      {
        "fieldValue": "LU 12/1992",
        "weight": 2
      }
    ]
  },
  {
    "fieldName": "city",
    "values": [
      {
        "fieldValue": "HOUSTON",
        "weight": 28
      },
      {
        "fieldValue": "SALEM",
        "weight": 15
      },
      {
        "fieldValue": "SPRINGFIELD",
        "weight": 11
      },
      {
        "fieldValue": "PLYMOUTH",
        "weight": 10
      },
      {
        "fieldValue": "CLINTON",
        "weight": 10
      },
      {
        "fieldValue": "ALBANY",
        "weight": 10
      },
      {
        "fieldValue": "COLUMBUS",
        "weight": 10
      },
      {
        "fieldValue": "COLUMBIA",
        "weight": 10
      },
      {
        "fieldValue": "MANSFIELD",
        "weight": 9
      },
      {
        "fieldValue": "DALLAS",
        "weight": 9
      }
    ]
  },
  {
    "fieldName": "cntl_twr",
    "values": [
      {
        "fieldValue": "N",
        "weight": 4839
      },
      {
        "fieldValue": "Y",
        "weight": 161
      }
    ]
  },
  {
    "fieldName": "code",
    "values": [
      {
        "fieldValue": "PS20",
        "weight": 1
      },
      {
        "fieldValue": "3W9",
        "weight": 1
      },
      {
        "fieldValue": "11AK",
        "weight": 1
      },
      {
        "fieldValue": "WA94",
        "weight": 1
      },
      {
        "fieldValue": "57WI",
        "weight": 1
      },
      {
        "fieldValue": "OG22",
        "weight": 1
      },
      {
        "fieldValue": "2AK",
        "weight": 1
      },
      {
        "fieldValue": "M13",
        "weight": 1
      },
      {
        "fieldValue": "RCX",
        "weight": 1
      },
      {
        "fieldValue": "2AK4",
        "weight": 1
      }
    ]
  },
  {
    "fieldName": "county",
    "values": [
      {
        "fieldValue": "WASHINGTON",
        "weight": 61
      },
      {
        "fieldValue": "FRANKLIN",
        "weight": 45
      },
      {
        "fieldValue": "MONTGOMERY",
        "weight": 44
      },
      {
        "fieldValue": "LOS ANGELES",
        "weight": 42
      },
      {
        "fieldValue": "LINCOLN",
        "weight": 41
      },
      {
        "fieldValue": "JACKSON",
        "weight": 37
      },
      {
        "fieldValue": "JEFFERSON",
        "weight": 36
      },
      {
        "fieldValue": "MARION",
        "weight": 33
      },
      {
        "fieldValue": "HARRIS",
        "weight": 30
      },
      {
        "fieldValue": "ADAMS",
        "weight": 29
      }
    ]
  },
  {
    "fieldName": "cust_intl",
    "values": [
      {
        "fieldValue": null,
        "weight": 3837
      },
      {
        "fieldValue": "N",
        "weight": 1149
      },
      {
        "fieldValue": "Y",
        "weight": 14
      }
    ]
  },
  {
    "fieldName": "elevation",
    "values": [
      {
        "fieldValue": "-113 to 10085",
        "weight": 5000
      }
    ]
  },
  {
    "fieldName": "faa_dist",
    "values": [
      {
        "fieldValue": "NONE",
        "weight": 1747
      },
      {
        "fieldValue": "CHI",
        "weight": 376
      },
      {
        "fieldValue": "DET",
        "weight": 323
      },
      {
        "fieldValue": "SEA",
        "weight": 305
      },
      {
        "fieldValue": "ATL",
        "weight": 276
      },
      {
        "fieldValue": "MSP",
        "weight": 265
      },
      {
        "fieldValue": "HAR",
        "weight": 231
      },
      {
        "fieldValue": "NYC",
        "weight": 231
      },
      {
        "fieldValue": "ORL",
        "weight": 206
      },
      {
        "fieldValue": "BIS",
        "weight": 191
      }
    ]
  },
  {
    "fieldName": "faa_region",
    "values": [
      {
        "fieldValue": "AGL",
        "weight": 1158
      },
      {
        "fieldValue": "ASW",
        "weight": 805
      },
      {
        "fieldValue": "ASO",
        "weight": 736
      },
      {
        "fieldValue": "AEA",
        "weight": 664
      },
      {
        "fieldValue": "ANM",
        "weight": 542
      },
      {
        "fieldValue": "ACE",
        "weight": 421
      },
      {
        "fieldValue": "AWP",
        "weight": 335
      },
      {
        "fieldValue": "ANE",
        "weight": 197
      },
      {
        "fieldValue": "AAL",
        "weight": 137
      },
      {
        "fieldValue": null,
        "weight": 5
      }
    ]
  },
  {
    "fieldName": "fac_type",
    "values": [
      {
        "fieldValue": "AIRPORT",
        "weight": 3540
      },
      {
        "fieldValue": "HELIPORT",
        "weight": 1274
      },
      {
        "fieldValue": "SEAPLANE BASE",
        "weight": 115
      },
      {
        "fieldValue": "ULTRALIGHT",
        "weight": 35
      },
      {
        "fieldValue": "STOLPORT",
        "weight": 20
      },
      {
        "fieldValue": "GLIDERPORT",
        "weight": 13
      },
      {
        "fieldValue": "BALLOONPORT",
        "weight": 3
      }
    ]
  },
  {
    "fieldName": "fac_use",
    "values": [
      {
        "fieldValue": "PR",
        "weight": 3631
      },
      {
        "fieldValue": "PU",
        "weight": 1369
      }
    ]
  },
  {
    "fieldName": "fed_agree",
    "values": [
      {
        "fieldValue": null,
        "weight": 4116
      },
      {
        "fieldValue": "NGY",
        "weight": 406
      },
      {
        "fieldValue": "N",
        "weight": 119
      },
      {
        "fieldValue": "NGY3",
        "weight": 63
      },
      {
        "fieldValue": "NGPY",
        "weight": 38
      },
      {
        "fieldValue": "NY1",
        "weight": 35
      },
      {
        "fieldValue": "1",
        "weight": 32
      },
      {
        "fieldValue": "NGSY",
        "weight": 20
      },
      {
        "fieldValue": "NGPY3",
        "weight": 20
      },
      {
        "fieldValue": "N1",
        "weight": 20
      }
    ]
  },
  {
    "fieldName": "full_name",
    "values": [
      {
        "fieldValue": "MEMORIAL HOSPITAL",
        "weight": 6
      },
      {
        "fieldValue": "MERCY HOSPITAL",
        "weight": 4
      },
      {
        "fieldValue": "DAVIS",
        "weight": 4
      },
      {
        "fieldValue": "MEDICAL CENTER",
        "weight": 4
      },
      {
        "fieldValue": "CLARK",
        "weight": 4
      },
      {
        "fieldValue": "ADAMS",
        "weight": 4
      },
      {
        "fieldValue": "FLYING W",
        "weight": 4
      },
      {
        "fieldValue": "FLYING H RANCH",
        "weight": 3
      },
      {
        "fieldValue": "ST JOSEPH'S HOSPITAL",
        "weight": 3
      },
      {
        "fieldValue": "RIVERSIDE",
        "weight": 3
      }
    ]
  },
  {
    "fieldName": "id",
    "values": [
      {
        "fieldValue": "10001 to 19789",
        "weight": 5000
      }
    ]
  },
  {
    "fieldName": "joint_use",
    "values": [
      {
        "fieldValue": null,
        "weight": 3733
      },
      {
        "fieldValue": "N",
        "weight": 1215
      },
      {
        "fieldValue": "Y",
        "weight": 52
      }
    ]
  },
  {
    "fieldName": "latitude",
    "values": [
      {
        "fieldValue": "-14.21 to 70.4",
        "weight": 5000
      }
    ]
  },
  {
    "fieldName": "longitude",
    "values": [
      {
        "fieldValue": "-100.0 to 170.88",
        "weight": 5000
      }
    ]
  },
  {
    "fieldName": "major",
    "values": [
      {
        "fieldValue": "N",
        "weight": 4933
      },
      {
        "fieldValue": "Y",
        "weight": 67
      }
    ]
  },
  {
    "fieldName": "mil_rts",
    "values": [
      {
        "fieldValue": null,
        "weight": 3714
      },
      {
        "fieldValue": "Y",
        "weight": 737
      },
      {
        "fieldValue": "N",
        "weight": 549
      }
    ]
  },
  {
    "fieldName": "own_type",
    "values": [
      {
        "fieldValue": "PR",
        "weight": 3605
      },
      {
        "fieldValue": "PU",
        "weight": 1328
      },
      {
        "fieldValue": "MR",
        "weight": 35
      },
      {
        "fieldValue": "MA",
        "weight": 20
      },
      {
        "fieldValue": "MN",
        "weight": 12
      }
    ]
  },
  {
    "fieldName": "site_number",
    "values": [
      {
        "fieldValue": "14789.2*H",
        "weight": 1
      },
      {
        "fieldValue": "10703.*A",
        "weight": 1
      },
      {
        "fieldValue": "19589.04*H",
        "weight": 1
      },
      {
        "fieldValue": "50320.2*A",
        "weight": 1
      },
      {
        "fieldValue": "50072.5*A",
        "weight": 1
      },
      {
        "fieldValue": "22780.5*A",
        "weight": 1
      },
      {
        "fieldValue": "50215.02*H",
        "weight": 1
      },
      {
        "fieldValue": "50325.*A",
        "weight": 1
      },
      {
        "fieldValue": "25928.5*H",
        "weight": 1
      },
      {
        "fieldValue": "05541.2*A",
        "weight": 1
      }
    ]
  },
  {
    "fieldName": "state",
    "values": [
      {
        "fieldValue": "TX",
        "weight": 455
      },
      {
        "fieldValue": "CA",
        "weight": 233
      },
      {
        "fieldValue": "PA",
        "weight": 219
      },
      {
        "fieldValue": "IL",
        "weight": 218
      },
      {
        "fieldValue": "OH",
        "weight": 200
      },
      {
        "fieldValue": "FL",
        "weight": 196
      },
      {
        "fieldValue": "IN",
        "weight": 160
      },
      {
        "fieldValue": "MO",
        "weight": 145
      },
      {
        "fieldValue": "LA",
        "weight": 140
      },
      {
        "fieldValue": "AK",
        "weight": 137
      }
    ]
  },
  {
    "fieldName": null,
    "values": [
      {
        "fieldValue": null,
        "weight": 5000
      }
    ]
  }
]
WITH __stage0 AS (
  SELECT * from (SELECT * FROM '../data/airports.parquet' USING SAMPLE 5000) as x limit 100000 )
, __stage1 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'act_date'
      WHEN 1 THEN 'aero_cht'
      WHEN 2 THEN 'c_ldg_rts'
      WHEN 3 THEN 'cbd_dir'
      WHEN 4 THEN 'cbd_dist'
      WHEN 5 THEN 'cert'
      WHEN 6 THEN 'city'
      WHEN 7 THEN 'cntl_twr'
      WHEN 8 THEN 'code'
      WHEN 9 THEN 'county'
      WHEN 10 THEN 'cust_intl'
      WHEN 11 THEN 'elevation'
      WHEN 12 THEN 'faa_dist'
      WHEN 13 THEN 'faa_region'
      WHEN 14 THEN 'fac_type'
      WHEN 15 THEN 'fac_use'
      WHEN 16 THEN 'fed_agree'
      WHEN 17 THEN 'full_name'
      WHEN 18 THEN 'id'
      WHEN 19 THEN 'joint_use'
      WHEN 20 THEN 'latitude'
      WHEN 21 THEN 'longitude'
      WHEN 22 THEN 'major'
      WHEN 23 THEN 'mil_rts'
      WHEN 24 THEN 'own_type'
      WHEN 25 THEN 'site_number'
      WHEN 26 THEN 'state'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'string'
      WHEN 1 THEN 'string'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'string'
      WHEN 4 THEN 'number'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'string'
      WHEN 7 THEN 'string'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'number'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
      WHEN 14 THEN 'string'
      WHEN 15 THEN 'string'
      WHEN 16 THEN 'string'
      WHEN 17 THEN 'string'
      WHEN 18 THEN 'number'
      WHEN 19 THEN 'string'
      WHEN 20 THEN 'number'
      WHEN 21 THEN 'number'
      WHEN 22 THEN 'string'
      WHEN 23 THEN 'string'
      WHEN 24 THEN 'string'
      WHEN 25 THEN 'string'
      WHEN 26 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 0 THEN base."act_date"
      WHEN 1 THEN base."aero_cht"
      WHEN 2 THEN base."c_ldg_rts"
      WHEN 3 THEN base."cbd_dir"
      WHEN 5 THEN base."cert"
      WHEN 6 THEN base."city"
      WHEN 7 THEN base."cntl_twr"
      WHEN 8 THEN base."code"
      WHEN 9 THEN base."county"
      WHEN 10 THEN base."cust_intl"
      WHEN 12 THEN base."faa_dist"
      WHEN 13 THEN base."faa_region"
      WHEN 14 THEN base."fac_type"
      WHEN 15 THEN base."fac_use"
      WHEN 16 THEN base."fed_agree"
      WHEN 17 THEN base."full_name"
      WHEN 19 THEN base."joint_use"
      WHEN 22 THEN base."major"
      WHEN 23 THEN base."mil_rts"
      WHEN 24 THEN base."own_type"
      WHEN 25 THEN base."site_number"
      WHEN 26 THEN base."state"
    END as "fieldValue",
   COUNT(*) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 4 THEN MIN(CAST(base."cbd_dist" as VARCHAR)) || ' to ' || CAST(MAX(base."cbd_dist") as VARCHAR)
      WHEN 11 THEN MIN(CAST(base."elevation" as VARCHAR)) || ' to ' || CAST(MAX(base."elevation") as VARCHAR)
      WHEN 18 THEN MIN(CAST(base."id" as VARCHAR)) || ' to ' || CAST(MAX(base."id") as VARCHAR)
      WHEN 20 THEN MIN(CAST(base."latitude" as VARCHAR)) || ' to ' || CAST(MAX(base."latitude") as VARCHAR)
      WHEN 21 THEN MIN(CAST(base."longitude" as VARCHAR)) || ' to ' || CAST(MAX(base."longitude") as VARCHAR)
    END as "fieldRange"
  FROM __stage0 as base
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,27,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
, __stage2 AS (
  SELECT
    "fieldName",
    "fieldPath",
    "fieldType",
    COALESCE("fieldValue", "fieldRange") as "fieldValue",
    weight
  FROM __stage1
)
, __stage3 AS (
  SELECT
    group_set,
    base."fieldName" as "fieldName__0",
    CASE WHEN group_set=1 THEN
      base."fieldValue"
      END as "fieldValue__1",
    CASE WHEN group_set=1 THEN
      base."weight"
      END as "weight__1"
  FROM __stage2 as base
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,1,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4
)
SELECT
  "fieldName__0" as "fieldName",
  COALESCE(LIST({
    "fieldValue": "fieldValue__1", 
    "weight": "weight__1"}  ORDER BY  "weight__1" desc NULLS LAST) FILTER (WHERE group_set=1)[1:10],[]) as "values"
FROM __stage3
GROUP BY 1
ORDER BY 1 ASC NULLS LAST

A More Complex Example

The rest of this pages uses the model below. The data is an excerpt from the IMDB. The Malloy schema for this model is shown on the right. The core value is movies, but joined at the principals (the people that worked on the movie) and the people (the actual data about the individuals).

We use the measure total_ratings to determin a movie's popularity. An individual's popularity is determined by the some of all the ratings of the movies a person has worked on.

document
source: movies is duckdb.table('../data/titles.parquet') extend {
  join_many: principals is duckdb.table('../data/principals.parquet') extend {
    join_one: people is duckdb.table('../data/names.parquet') 
      on nconst = people.nconst
  } on tconst = principals.tconst
  measure: total_ratings is numVotes.sum()
}

Weights can be any measure

Often a row count will work nicely as a weight, but sometimes there is something better. In movies, for example the sum of the number of votes will not only find the interesting most interesting movies but will also find the most interesting people. For example the most interesting people in the dataset.

document
run: movies -> {
  group_by: principals.people.primaryName
  aggregate: total_ratings
} 
QUERY RESULTS
primaryNametotal_​ratings
Brad Pitt18,269,386
Stan Lee18,229,893
John Williams17,651,379
Leonardo DiCaprio17,032,662
Tom Hanks16,650,835
Christopher Nolan15,368,415
Steven Spielberg15,069,082
Robert De Niro14,629,861
Christian Bale13,730,681
Samuel L. Jackson13,423,134
Robert Downey Jr.12,685,331
George Lucas12,584,331
Matt Damon12,509,393
Quentin Tarantino12,348,394
Bruce Willis12,045,753
Jack Kirby11,901,244
Johnny Depp11,755,228
Morgan Freeman11,435,905
Tom Cruise11,290,573
Thomas Newman11,056,371
Hans Zimmer10,957,053
Scott Rudin10,793,692
Charles Roven10,778,794
Bob Kane10,685,405
Ian McKellen10,552,024
Chris Evans10,497,785
Harrison Ford10,449,365
Scarlett Johansson10,128,373
David S. Goyer10,022,517
Jonathan Nolan9,823,211
Martin Scorsese9,692,050
Peter Jackson9,612,306
Orlando Bloom9,482,690
James Newton Howard9,473,293
Stephen King9,454,020
Hugh Jackman9,409,702
Kevin Feige9,408,976
Ridley Scott9,334,292
Natalie Portman9,206,903
Liam Neeson9,185,450
David Heyman9,174,472
Mark Ruffalo9,171,115
Bradley Cooper8,980,668
Will Smith8,960,562
Al Pacino8,933,776
Emma Thomas8,773,124
Tim Bevan8,756,327
Roger Deakins8,737,852
Fran Walsh8,594,296
Michael Caine8,533,028
Lorne Orleans8,518,672
Lawrence Bender8,503,500
Keanu Reeves8,480,149
David Fincher8,427,910
Mark Wahlberg8,393,193
Joel Silver8,360,819
Robert Richardson8,351,268
Philippa Boyens8,336,233
Kathleen Kennedy8,278,785
Matthew McConaughey8,271,368
Ben Affleck8,268,036
James Horner8,253,828
Alan Silvestri8,072,953
Chris Hemsworth8,058,188
Carter Burwell7,997,536
Simon Kinberg7,846,138
Eric Fellner7,845,245
J.R.R. Tolkien7,798,667
Jake Gyllenhaal7,762,048
Jerry Bruckheimer7,721,877
Edward Norton7,713,816
Woody Harrelson7,711,063
Ewan McGregor7,655,458
George Clooney7,653,368
David Benioff7,637,309
Kevin Spacey7,603,094
Brian Grazer7,570,625
Anne Hathaway7,509,220
Arnon Milchan7,494,607
Jim Carrey7,421,247
Robert Zemeckis7,371,523
Danny Elfman7,340,555
Ryan Reynolds7,319,537
Jason Blum7,308,653
James Cameron7,306,015
Sally Menke7,239,769
Tom Hardy7,213,428
Clint Eastwood7,209,434
Russell Crowe7,166,573
Akiva Goldsman7,094,797
Nicolas Cage7,053,952
Michael Giacchino7,047,025
Gary Oldman7,036,991
Cate Blanchett7,017,425
Michael Bay7,016,200
J.J. Abrams6,991,513
Willem Dafoe6,924,815
Christopher Markus6,886,318
Stephen McFeely6,886,318
Neal H. Moritz6,870,329
Alexandre Desplat6,867,309
Jennifer Lawrence6,855,625
Rachel McAdams6,777,091
Lena Headey6,742,472
Elijah Wood6,734,358
Dwayne Johnson6,584,416
Jason Statham6,582,293
Steve Kloves6,559,963
Denzel Washington6,556,554
Sigourney Weaver6,515,096
Arnold Schwarzenegger6,482,925
Tim Burton6,467,281
Steve Carell6,436,581
Terry Rossio6,423,369
Ceán Chaffin6,415,865
Amy Adams6,401,556
Daniel Radcliffe6,393,663
J.K. Rowling6,392,020
Mel Gibson6,322,650
Anthony Hopkins6,315,913
Emma Watson6,304,351
6,300,267
Rick McCallum6,211,607
Jack Nicholson6,180,622
Ted Elliott6,136,354
Adam Sandler6,094,935
Ed Harris6,077,615
Chris Columbus6,076,896
Cameron Diaz6,042,333
Joseph Gordon-Levitt6,034,397
Emilia Clarke5,995,245
D.B. Weiss5,972,128
Joaquin Phoenix5,967,875
Daniel Craig5,967,704
Luc Besson5,961,182
Ryan Gosling5,956,376
Vin Diesel5,944,056
Andrew Stanton5,942,167
John Goodman5,940,986
Ralph Fiennes5,906,715
Peter Dinklage5,906,118
David Koepp5,894,926
Pete Docter5,862,141
Sylvester Stallone5,861,981
Angelina Jolie5,857,481
Ian Bryce5,848,379
Hugo Weaving5,841,890
Frank Darabont5,826,908
Ben Kingsley5,825,798
Viggo Mortensen5,823,719
Richard Francis-Bruce5,798,818
Colin Farrell5,788,835
Charlize Theron5,765,794
Joss Whedon5,757,097
Nikolaj Coster-Waldau5,749,486
Julianne Moore5,744,632
Jonah Hill5,718,674
Joel Coen5,700,458
Zack Snyder5,695,090
Ben Stiller5,685,709
Bryan Cranston5,685,238
Kate Winslet5,682,918
Ethan Coen5,663,547
Walter F. Parkes5,657,162
Howard Shore5,638,214
Jeremy Renner5,623,966
Marco Beltrami5,590,317
Bryan Singer5,590,237
Emma Stone5,583,422
Guillermo del Toro5,570,240
Owen Wilson5,556,539
Rupert Grint5,552,590
Jude Law5,538,884
Matthew Vaughn5,524,297
Alex Kurtzman5,522,344
Lana Wachowski5,518,169
Keira Knightley5,512,152
Lilly Wachowski5,444,217
Judd Apatow5,443,590
Chris Pratt5,439,043
Francis Ford Coppola5,436,313
Will Ferrell5,420,626
Seth Rogen5,419,570
Sandra Bullock5,405,221
Steve Ditko5,371,488
Frank Marshall5,363,210
John Logan5,353,165
Ken Watanabe5,352,344
Sam Raimi5,334,765
Carrie-Anne Moss5,305,827
Benedict Cumberbatch5,273,615
Robin Williams5,224,218
Jennifer Connelly5,222,568
Ron Howard5,215,903
John Travolta5,206,564
Laurence Fishburne5,187,514
Ethan Hawke5,186,955
Jamie Foxx5,180,837
Lawrence Kasdan5,173,484
Gerard Butler5,156,049
[
  {
    "primaryName": "Brad Pitt",
    "total_ratings": 18269386
  },
  {
    "primaryName": "Stan Lee",
    "total_ratings": 18229893
  },
  {
    "primaryName": "John Williams",
    "total_ratings": 17651379
  },
  {
    "primaryName": "Leonardo DiCaprio",
    "total_ratings": 17032662
  },
  {
    "primaryName": "Tom Hanks",
    "total_ratings": 16650835
  },
  {
    "primaryName": "Christopher Nolan",
    "total_ratings": 15368415
  },
  {
    "primaryName": "Steven Spielberg",
    "total_ratings": 15069082
  },
  {
    "primaryName": "Robert De Niro",
    "total_ratings": 14629861
  },
  {
    "primaryName": "Christian Bale",
    "total_ratings": 13730681
  },
  {
    "primaryName": "Samuel L. Jackson",
    "total_ratings": 13423134
  },
  {
    "primaryName": "Robert Downey Jr.",
    "total_ratings": 12685331
  },
  {
    "primaryName": "George Lucas",
    "total_ratings": 12584331
  },
  {
    "primaryName": "Matt Damon",
    "total_ratings": 12509393
  },
  {
    "primaryName": "Quentin Tarantino",
    "total_ratings": 12348394
  },
  {
    "primaryName": "Bruce Willis",
    "total_ratings": 12045753
  },
  {
    "primaryName": "Jack Kirby",
    "total_ratings": 11901244
  },
  {
    "primaryName": "Johnny Depp",
    "total_ratings": 11755228
  },
  {
    "primaryName": "Morgan Freeman",
    "total_ratings": 11435905
  },
  {
    "primaryName": "Tom Cruise",
    "total_ratings": 11290573
  },
  {
    "primaryName": "Thomas Newman",
    "total_ratings": 11056371
  },
  {
    "primaryName": "Hans Zimmer",
    "total_ratings": 10957053
  },
  {
    "primaryName": "Scott Rudin",
    "total_ratings": 10793692
  },
  {
    "primaryName": "Charles Roven",
    "total_ratings": 10778794
  },
  {
    "primaryName": "Bob Kane",
    "total_ratings": 10685405
  },
  {
    "primaryName": "Ian McKellen",
    "total_ratings": 10552024
  },
  {
    "primaryName": "Chris Evans",
    "total_ratings": 10497785
  },
  {
    "primaryName": "Harrison Ford",
    "total_ratings": 10449365
  },
  {
    "primaryName": "Scarlett Johansson",
    "total_ratings": 10128373
  },
  {
    "primaryName": "David S. Goyer",
    "total_ratings": 10022517
  },
  {
    "primaryName": "Jonathan Nolan",
    "total_ratings": 9823211
  },
  {
    "primaryName": "Martin Scorsese",
    "total_ratings": 9692050
  },
  {
    "primaryName": "Peter Jackson",
    "total_ratings": 9612306
  },
  {
    "primaryName": "Orlando Bloom",
    "total_ratings": 9482690
  },
  {
    "primaryName": "James Newton Howard",
    "total_ratings": 9473293
  },
  {
    "primaryName": "Stephen King",
    "total_ratings": 9454020
  },
  {
    "primaryName": "Hugh Jackman",
    "total_ratings": 9409702
  },
  {
    "primaryName": "Kevin Feige",
    "total_ratings": 9408976
  },
  {
    "primaryName": "Ridley Scott",
    "total_ratings": 9334292
  },
  {
    "primaryName": "Natalie Portman",
    "total_ratings": 9206903
  },
  {
    "primaryName": "Liam Neeson",
    "total_ratings": 9185450
  },
  {
    "primaryName": "David Heyman",
    "total_ratings": 9174472
  },
  {
    "primaryName": "Mark Ruffalo",
    "total_ratings": 9171115
  },
  {
    "primaryName": "Bradley Cooper",
    "total_ratings": 8980668
  },
  {
    "primaryName": "Will Smith",
    "total_ratings": 8960562
  },
  {
    "primaryName": "Al Pacino",
    "total_ratings": 8933776
  },
  {
    "primaryName": "Emma Thomas",
    "total_ratings": 8773124
  },
  {
    "primaryName": "Tim Bevan",
    "total_ratings": 8756327
  },
  {
    "primaryName": "Roger Deakins",
    "total_ratings": 8737852
  },
  {
    "primaryName": "Fran Walsh",
    "total_ratings": 8594296
  },
  {
    "primaryName": "Michael Caine",
    "total_ratings": 8533028
  },
  {
    "primaryName": "Lorne Orleans",
    "total_ratings": 8518672
  },
  {
    "primaryName": "Lawrence Bender",
    "total_ratings": 8503500
  },
  {
    "primaryName": "Keanu Reeves",
    "total_ratings": 8480149
  },
  {
    "primaryName": "David Fincher",
    "total_ratings": 8427910
  },
  {
    "primaryName": "Mark Wahlberg",
    "total_ratings": 8393193
  },
  {
    "primaryName": "Joel Silver",
    "total_ratings": 8360819
  },
  {
    "primaryName": "Robert Richardson",
    "total_ratings": 8351268
  },
  {
    "primaryName": "Philippa Boyens",
    "total_ratings": 8336233
  },
  {
    "primaryName": "Kathleen Kennedy",
    "total_ratings": 8278785
  },
  {
    "primaryName": "Matthew McConaughey",
    "total_ratings": 8271368
  },
  {
    "primaryName": "Ben Affleck",
    "total_ratings": 8268036
  },
  {
    "primaryName": "James Horner",
    "total_ratings": 8253828
  },
  {
    "primaryName": "Alan Silvestri",
    "total_ratings": 8072953
  },
  {
    "primaryName": "Chris Hemsworth",
    "total_ratings": 8058188
  },
  {
    "primaryName": "Carter Burwell",
    "total_ratings": 7997536
  },
  {
    "primaryName": "Simon Kinberg",
    "total_ratings": 7846138
  },
  {
    "primaryName": "Eric Fellner",
    "total_ratings": 7845245
  },
  {
    "primaryName": "J.R.R. Tolkien",
    "total_ratings": 7798667
  },
  {
    "primaryName": "Jake Gyllenhaal",
    "total_ratings": 7762048
  },
  {
    "primaryName": "Jerry Bruckheimer",
    "total_ratings": 7721877
  },
  {
    "primaryName": "Edward Norton",
    "total_ratings": 7713816
  },
  {
    "primaryName": "Woody Harrelson",
    "total_ratings": 7711063
  },
  {
    "primaryName": "Ewan McGregor",
    "total_ratings": 7655458
  },
  {
    "primaryName": "George Clooney",
    "total_ratings": 7653368
  },
  {
    "primaryName": "David Benioff",
    "total_ratings": 7637309
  },
  {
    "primaryName": "Kevin Spacey",
    "total_ratings": 7603094
  },
  {
    "primaryName": "Brian Grazer",
    "total_ratings": 7570625
  },
  {
    "primaryName": "Anne Hathaway",
    "total_ratings": 7509220
  },
  {
    "primaryName": "Arnon Milchan",
    "total_ratings": 7494607
  },
  {
    "primaryName": "Jim Carrey",
    "total_ratings": 7421247
  },
  {
    "primaryName": "Robert Zemeckis",
    "total_ratings": 7371523
  },
  {
    "primaryName": "Danny Elfman",
    "total_ratings": 7340555
  },
  {
    "primaryName": "Ryan Reynolds",
    "total_ratings": 7319537
  },
  {
    "primaryName": "Jason Blum",
    "total_ratings": 7308653
  },
  {
    "primaryName": "James Cameron",
    "total_ratings": 7306015
  },
  {
    "primaryName": "Sally Menke",
    "total_ratings": 7239769
  },
  {
    "primaryName": "Tom Hardy",
    "total_ratings": 7213428
  },
  {
    "primaryName": "Clint Eastwood",
    "total_ratings": 7209434
  },
  {
    "primaryName": "Russell Crowe",
    "total_ratings": 7166573
  },
  {
    "primaryName": "Akiva Goldsman",
    "total_ratings": 7094797
  },
  {
    "primaryName": "Nicolas Cage",
    "total_ratings": 7053952
  },
  {
    "primaryName": "Michael Giacchino",
    "total_ratings": 7047025
  },
  {
    "primaryName": "Gary Oldman",
    "total_ratings": 7036991
  },
  {
    "primaryName": "Cate Blanchett",
    "total_ratings": 7017425
  },
  {
    "primaryName": "Michael Bay",
    "total_ratings": 7016200
  },
  {
    "primaryName": "J.J. Abrams",
    "total_ratings": 6991513
  },
  {
    "primaryName": "Willem Dafoe",
    "total_ratings": 6924815
  },
  {
    "primaryName": "Christopher Markus",
    "total_ratings": 6886318
  },
  {
    "primaryName": "Stephen McFeely",
    "total_ratings": 6886318
  },
  {
    "primaryName": "Neal H. Moritz",
    "total_ratings": 6870329
  },
  {
    "primaryName": "Alexandre Desplat",
    "total_ratings": 6867309
  },
  {
    "primaryName": "Jennifer Lawrence",
    "total_ratings": 6855625
  },
  {
    "primaryName": "Rachel McAdams",
    "total_ratings": 6777091
  },
  {
    "primaryName": "Lena Headey",
    "total_ratings": 6742472
  },
  {
    "primaryName": "Elijah Wood",
    "total_ratings": 6734358
  },
  {
    "primaryName": "Dwayne Johnson",
    "total_ratings": 6584416
  },
  {
    "primaryName": "Jason Statham",
    "total_ratings": 6582293
  },
  {
    "primaryName": "Steve Kloves",
    "total_ratings": 6559963
  },
  {
    "primaryName": "Denzel Washington",
    "total_ratings": 6556554
  },
  {
    "primaryName": "Sigourney Weaver",
    "total_ratings": 6515096
  },
  {
    "primaryName": "Arnold Schwarzenegger",
    "total_ratings": 6482925
  },
  {
    "primaryName": "Tim Burton",
    "total_ratings": 6467281
  },
  {
    "primaryName": "Steve Carell",
    "total_ratings": 6436581
  },
  {
    "primaryName": "Terry Rossio",
    "total_ratings": 6423369
  },
  {
    "primaryName": "Ceán Chaffin",
    "total_ratings": 6415865
  },
  {
    "primaryName": "Amy Adams",
    "total_ratings": 6401556
  },
  {
    "primaryName": "Daniel Radcliffe",
    "total_ratings": 6393663
  },
  {
    "primaryName": "J.K. Rowling",
    "total_ratings": 6392020
  },
  {
    "primaryName": "Mel Gibson",
    "total_ratings": 6322650
  },
  {
    "primaryName": "Anthony Hopkins",
    "total_ratings": 6315913
  },
  {
    "primaryName": "Emma Watson",
    "total_ratings": 6304351
  },
  {
    "primaryName": null,
    "total_ratings": 6300267
  },
  {
    "primaryName": "Rick McCallum",
    "total_ratings": 6211607
  },
  {
    "primaryName": "Jack Nicholson",
    "total_ratings": 6180622
  },
  {
    "primaryName": "Ted Elliott",
    "total_ratings": 6136354
  },
  {
    "primaryName": "Adam Sandler",
    "total_ratings": 6094935
  },
  {
    "primaryName": "Ed Harris",
    "total_ratings": 6077615
  },
  {
    "primaryName": "Chris Columbus",
    "total_ratings": 6076896
  },
  {
    "primaryName": "Cameron Diaz",
    "total_ratings": 6042333
  },
  {
    "primaryName": "Joseph Gordon-Levitt",
    "total_ratings": 6034397
  },
  {
    "primaryName": "Emilia Clarke",
    "total_ratings": 5995245
  },
  {
    "primaryName": "D.B. Weiss",
    "total_ratings": 5972128
  },
  {
    "primaryName": "Joaquin Phoenix",
    "total_ratings": 5967875
  },
  {
    "primaryName": "Daniel Craig",
    "total_ratings": 5967704
  },
  {
    "primaryName": "Luc Besson",
    "total_ratings": 5961182
  },
  {
    "primaryName": "Ryan Gosling",
    "total_ratings": 5956376
  },
  {
    "primaryName": "Vin Diesel",
    "total_ratings": 5944056
  },
  {
    "primaryName": "Andrew Stanton",
    "total_ratings": 5942167
  },
  {
    "primaryName": "John Goodman",
    "total_ratings": 5940986
  },
  {
    "primaryName": "Ralph Fiennes",
    "total_ratings": 5906715
  },
  {
    "primaryName": "Peter Dinklage",
    "total_ratings": 5906118
  },
  {
    "primaryName": "David Koepp",
    "total_ratings": 5894926
  },
  {
    "primaryName": "Pete Docter",
    "total_ratings": 5862141
  },
  {
    "primaryName": "Sylvester Stallone",
    "total_ratings": 5861981
  },
  {
    "primaryName": "Angelina Jolie",
    "total_ratings": 5857481
  },
  {
    "primaryName": "Ian Bryce",
    "total_ratings": 5848379
  },
  {
    "primaryName": "Hugo Weaving",
    "total_ratings": 5841890
  },
  {
    "primaryName": "Frank Darabont",
    "total_ratings": 5826908
  },
  {
    "primaryName": "Ben Kingsley",
    "total_ratings": 5825798
  },
  {
    "primaryName": "Viggo Mortensen",
    "total_ratings": 5823719
  },
  {
    "primaryName": "Richard Francis-Bruce",
    "total_ratings": 5798818
  },
  {
    "primaryName": "Colin Farrell",
    "total_ratings": 5788835
  },
  {
    "primaryName": "Charlize Theron",
    "total_ratings": 5765794
  },
  {
    "primaryName": "Joss Whedon",
    "total_ratings": 5757097
  },
  {
    "primaryName": "Nikolaj Coster-Waldau",
    "total_ratings": 5749486
  },
  {
    "primaryName": "Julianne Moore",
    "total_ratings": 5744632
  },
  {
    "primaryName": "Jonah Hill",
    "total_ratings": 5718674
  },
  {
    "primaryName": "Joel Coen",
    "total_ratings": 5700458
  },
  {
    "primaryName": "Zack Snyder",
    "total_ratings": 5695090
  },
  {
    "primaryName": "Ben Stiller",
    "total_ratings": 5685709
  },
  {
    "primaryName": "Bryan Cranston",
    "total_ratings": 5685238
  },
  {
    "primaryName": "Kate Winslet",
    "total_ratings": 5682918
  },
  {
    "primaryName": "Ethan Coen",
    "total_ratings": 5663547
  },
  {
    "primaryName": "Walter F. Parkes",
    "total_ratings": 5657162
  },
  {
    "primaryName": "Howard Shore",
    "total_ratings": 5638214
  },
  {
    "primaryName": "Jeremy Renner",
    "total_ratings": 5623966
  },
  {
    "primaryName": "Marco Beltrami",
    "total_ratings": 5590317
  },
  {
    "primaryName": "Bryan Singer",
    "total_ratings": 5590237
  },
  {
    "primaryName": "Emma Stone",
    "total_ratings": 5583422
  },
  {
    "primaryName": "Guillermo del Toro",
    "total_ratings": 5570240
  },
  {
    "primaryName": "Owen Wilson",
    "total_ratings": 5556539
  },
  {
    "primaryName": "Rupert Grint",
    "total_ratings": 5552590
  },
  {
    "primaryName": "Jude Law",
    "total_ratings": 5538884
  },
  {
    "primaryName": "Matthew Vaughn",
    "total_ratings": 5524297
  },
  {
    "primaryName": "Alex Kurtzman",
    "total_ratings": 5522344
  },
  {
    "primaryName": "Lana Wachowski",
    "total_ratings": 5518169
  },
  {
    "primaryName": "Keira Knightley",
    "total_ratings": 5512152
  },
  {
    "primaryName": "Lilly Wachowski",
    "total_ratings": 5444217
  },
  {
    "primaryName": "Judd Apatow",
    "total_ratings": 5443590
  },
  {
    "primaryName": "Chris Pratt",
    "total_ratings": 5439043
  },
  {
    "primaryName": "Francis Ford Coppola",
    "total_ratings": 5436313
  },
  {
    "primaryName": "Will Ferrell",
    "total_ratings": 5420626
  },
  {
    "primaryName": "Seth Rogen",
    "total_ratings": 5419570
  },
  {
    "primaryName": "Sandra Bullock",
    "total_ratings": 5405221
  },
  {
    "primaryName": "Steve Ditko",
    "total_ratings": 5371488
  },
  {
    "primaryName": "Frank Marshall",
    "total_ratings": 5363210
  },
  {
    "primaryName": "John Logan",
    "total_ratings": 5353165
  },
  {
    "primaryName": "Ken Watanabe",
    "total_ratings": 5352344
  },
  {
    "primaryName": "Sam Raimi",
    "total_ratings": 5334765
  },
  {
    "primaryName": "Carrie-Anne Moss",
    "total_ratings": 5305827
  },
  {
    "primaryName": "Benedict Cumberbatch",
    "total_ratings": 5273615
  },
  {
    "primaryName": "Robin Williams",
    "total_ratings": 5224218
  },
  {
    "primaryName": "Jennifer Connelly",
    "total_ratings": 5222568
  },
  {
    "primaryName": "Ron Howard",
    "total_ratings": 5215903
  },
  {
    "primaryName": "John Travolta",
    "total_ratings": 5206564
  },
  {
    "primaryName": "Laurence Fishburne",
    "total_ratings": 5187514
  },
  {
    "primaryName": "Ethan Hawke",
    "total_ratings": 5186955
  },
  {
    "primaryName": "Jamie Foxx",
    "total_ratings": 5180837
  },
  {
    "primaryName": "Lawrence Kasdan",
    "total_ratings": 5173484
  },
  {
    "primaryName": "Gerard Butler",
    "total_ratings": 5156049
  }
]
SELECT 
   people_0."primaryName" as "primaryName",
   COALESCE((
        SELECT SUM(a.val) as value
        FROM (
          SELECT UNNEST(list(distinct {key:movies."__distinct_key", val: movies."numVotes"})) a
        )
      ),0) as "total_ratings"
FROM (SELECT GEN_RANDOM_UUID() as __distinct_key, x.*  FROM '../data/titles.parquet' as x) as movies
 LEFT JOIN '../data/principals.parquet' AS principals_0
  ON movies."tconst"=principals_0."tconst"
 LEFT JOIN '../data/names.parquet' AS people_0
  ON principals_0."nconst"=people_0."nconst"
GROUP BY 1
ORDER BY 2 desc NULLS LAST

Index the entire graph

Indexing can work across an entire network of joins and can be selective.

document
run: movies -> {
  index:
    *
    genres.*
    principals.category, principals.job
    principals.characters.*
    principals.people.primaryName
  by total_ratings
  sample: 5000
} -> {
  select: *
  order_by: weight desc
}
QUERY RESULTS
fieldNamefieldPathfieldTypefieldValueweight
averageRatingaverageRatingnumber1.0 to 10.0714,469,771
endYearendYearnumber1964.0 to 2024.0714,469,771
isAdultisAdultstring0714,469,771
numVotesnumVotesnumber100038.0 to 2755400.0714,469,771
runtimeMinutesruntimeMinutesnumber100.0 to 780.0714,469,771
startYearstartYearnumber1920.0 to 2023.0714,469,771
714,469,771
principals.jobprincipals/jobstring\N710,157,083
principals.categoryprincipals/categorystringactor701,487,296
principals.characters.valueprincipals/characters/valuestring\N699,848,852
principals.categoryprincipals/categorystringdirector620,204,196
principals.categoryprincipals/categorystringwriter607,504,744
principals.categoryprincipals/categorystringactress602,626,378
principals.categoryprincipals/categorystringproducer537,269,065
principals.jobprincipals/jobstringproducer535,386,766
genres.valuegenres/valuestringDrama359,114,628
principals.categoryprincipals/categorystringcomposer312,605,800
genres.valuegenres/valuestringAction264,226,875
principals.categoryprincipals/categorystringcinematographer224,101,431
genres.valuegenres/valuestringAdventure215,611,055
genres.valuegenres/valuestringComedy212,507,003
principals.jobprincipals/jobstringscreenplay177,562,290
principals.jobprincipals/jobstringdirector of photography168,243,129
principals.jobprincipals/jobstringwritten by165,087,869
genres.valuegenres/valuestringCrime145,729,251
principals.categoryprincipals/categorystringeditor132,908,043
genres.valuegenres/valuestringThriller114,203,967
principals.jobprincipals/jobstringscreenplay by104,649,227
genres.valuegenres/valuestringSci-Fi90,975,508
genres.valuegenres/valuestringMystery75,660,294
genres.valuegenres/valuestringFantasy74,967,764
genres.valuegenres/valuestringRomance74,817,238
genres.valuegenres/valuestringHorror64,058,121
principals.jobprincipals/jobstringstory57,869,437
genres.valuegenres/valuestringAnimation55,199,540
genres.valuegenres/valuestringBiography47,161,526
principals.categoryprincipals/categorystringproduction_designer40,349,341
principals.jobprincipals/jobstringcreated by40,026,996
principals.jobprincipals/jobstringnovel35,861,643
principals.jobprincipals/jobstringstory by33,261,702
genres.valuegenres/valuestringFamily29,671,871
principals.jobprincipals/jobstringcharacters26,267,654
genres.valuegenres/valuestringHistory20,121,196
principals.jobprincipals/jobstringbased on the novel by17,698,559
principals.people.primaryNameprincipals/people/primaryNamestringLeonardo DiCaprio16,129,810
principals.people.primaryNameprincipals/people/primaryNamestringBrad Pitt15,289,297
principals.jobprincipals/jobstringbook13,755,649
principals.people.primaryNameprincipals/people/primaryNamestringTom Hanks13,142,846
genres.valuegenres/valuestringWar13,138,049
principals.people.primaryNameprincipals/people/primaryNamestringChristopher Nolan13,112,845
genres.valuegenres/valuestringMusic12,874,450
principals.jobprincipals/jobstringfilm editor12,309,812
principals.people.primaryNameprincipals/people/primaryNamestringChristian Bale12,050,004
principals.people.primaryNameprincipals/people/primaryNamestringRobert De Niro12,046,334
principals.people.primaryNameprincipals/people/primaryNamestringSamuel L. Jackson11,809,747
principals.jobprincipals/jobstringco-director11,252,962
principals.people.primaryNameprincipals/people/primaryNamestringQuentin Tarantino11,242,958
principals.people.primaryNameprincipals/people/primaryNamestringJohn Williams10,867,148
principals.jobprincipals/jobstringbased on characters created by10,782,925
principals.people.primaryNameprincipals/people/primaryNamestringStan Lee10,444,364
principals.people.primaryNameprincipals/people/primaryNamestringCharles Roven10,305,308
genres.valuegenres/valuestringSport10,216,137
principals.jobprincipals/jobstringdeveloped by9,945,597
principals.people.primaryNameprincipals/people/primaryNamestringIan McKellen9,759,427
principals.people.primaryNameprincipals/people/primaryNamestringBob Kane9,719,269
principals.people.primaryNameprincipals/people/primaryNamestringSteven Spielberg9,687,830
principals.characters.valueprincipals/characters/valuestringBatman9,644,754
principals.people.primaryNameprincipals/people/primaryNamestringThomas Newman9,579,153
principals.people.primaryNameprincipals/people/primaryNamestringTom Cruise9,422,729
principals.people.primaryNameprincipals/people/primaryNamestringJohnny Depp9,348,470
principals.characters.valueprincipals/characters/valuestringBruce Wayne9,340,134
principals.people.primaryNameprincipals/people/primaryNamestringMorgan Freeman9,187,609
principals.people.primaryNameprincipals/people/primaryNamestringMatt Damon9,149,079
principals.people.primaryNameprincipals/people/primaryNamestringDavid S. Goyer9,085,091
principals.jobprincipals/jobstringbased on the Marvel comics by9,055,763
principals.people.primaryNameprincipals/people/primaryNamestringPeter Jackson8,906,644
principals.people.primaryNameprincipals/people/primaryNamestringOrlando Bloom8,895,876
principals.people.primaryNameprincipals/people/primaryNamestringBruce Willis8,711,181
principals.people.primaryNameprincipals/people/primaryNamestringMartin Scorsese8,700,354
principals.people.primaryNameprincipals/people/primaryNamestringBradley Cooper8,425,640
principals.people.primaryNameprincipals/people/primaryNamestringStephen King8,376,793
principals.people.primaryNameprincipals/people/primaryNamestringJonathan Nolan8,343,275
principals.people.primaryNameprincipals/people/primaryNamestringLiam Neeson8,209,528
principals.people.primaryNameprincipals/people/primaryNamestringLawrence Bender8,205,607
principals.people.primaryNameprincipals/people/primaryNamestringMichael Caine8,183,734
principals.people.primaryNameprincipals/people/primaryNamestringHans Zimmer8,120,419
principals.people.primaryNameprincipals/people/primaryNamestringEmma Thomas8,088,224
principals.people.primaryNameprincipals/people/primaryNamestringFran Walsh7,936,766
principals.people.primaryNameprincipals/people/primaryNamestringPhilippa Boyens7,770,741
principals.people.primaryNameprincipals/people/primaryNamestringJ.R.R. Tolkien7,711,979
principals.people.primaryNameprincipals/people/primaryNamestringRobert Richardson7,709,024
principals.characters.valueprincipals/characters/valuestringGandalf7,631,041
principals.people.primaryNameprincipals/people/primaryNamestringGeorge Lucas7,585,197
principals.jobprincipals/jobstringbased on the book by7,560,659
principals.people.primaryNameprincipals/people/primaryNamestringJack Kirby7,535,566
principals.people.primaryNameprincipals/people/primaryNamestringLorne Orleans7,371,423
principals.people.primaryNameprincipals/people/primaryNamestringDavid Fincher7,254,941
principals.people.primaryNameprincipals/people/primaryNamestringSally Menke7,239,769
principals.people.primaryNameprincipals/people/primaryNamestringNatalie Portman7,173,322
principals.people.primaryNameprincipals/people/primaryNamestringMark Ruffalo7,156,155
principals.people.primaryNameprincipals/people/primaryNamestringMark Wahlberg7,152,730
principals.people.primaryNameprincipals/people/primaryNamestringRidley Scott6,860,931
principals.people.primaryNameprincipals/people/primaryNamestringJames Horner6,849,235
principals.people.primaryNameprincipals/people/primaryNamestringEdward Norton6,729,200
principals.people.primaryNameprincipals/people/primaryNamestringHugh Jackman6,674,864
principals.people.primaryNameprincipals/people/primaryNamestringAl Pacino6,660,396
principals.people.primaryNameprincipals/people/primaryNamestringRoger Deakins6,610,720
principals.people.primaryNameprincipals/people/primaryNamestringBrian Grazer6,556,669
principals.people.primaryNameprincipals/people/primaryNamestringAnne Hathaway6,555,118
principals.people.primaryNameprincipals/people/primaryNamestringChris Evans6,534,707
principals.people.primaryNameprincipals/people/primaryNamestringElijah Wood6,483,293
principals.people.primaryNameprincipals/people/primaryNamestringJerry Bruckheimer6,461,054
principals.people.primaryNameprincipals/people/primaryNamestringBen Affleck6,453,066
principals.people.primaryNameprincipals/people/primaryNamestringMatthew McConaughey6,445,973
principals.people.primaryNameprincipals/people/primaryNamestringKevin Feige6,443,135
principals.people.primaryNameprincipals/people/primaryNamestringTim Bevan6,428,885
principals.people.primaryNameprincipals/people/primaryNamestringRobert Downey Jr.6,406,323
principals.people.primaryNameprincipals/people/primaryNamestringDavid Heyman6,374,985
principals.people.primaryNameprincipals/people/primaryNamestringScarlett Johansson6,298,000
principals.people.primaryNameprincipals/people/primaryNamestringWill Smith6,271,538
principals.people.primaryNameprincipals/people/primaryNamestringChris Hemsworth6,215,489
principals.people.primaryNameprincipals/people/primaryNamestringJames Cameron6,208,367
principals.people.primaryNameprincipals/people/primaryNamestringJames Newton Howard6,099,103
principals.people.primaryNameprincipals/people/primaryNamestringDanny Elfman6,068,336
principals.people.primaryNameprincipals/people/primaryNamestringHarrison Ford6,033,086
principals.people.primaryNameprincipals/people/primaryNamestringCate Blanchett5,991,509
principals.people.primaryNameprincipals/people/primaryNamestringEwan McGregor5,913,545
principals.people.primaryNameprincipals/people/primaryNamestringMel Gibson5,885,534
principals.people.primaryNameprincipals/people/primaryNamestringRobert Zemeckis5,866,737
principals.people.primaryNameprincipals/people/primaryNamestringPete Docter5,862,141
principals.people.primaryNameprincipals/people/primaryNamestringEric Fellner5,838,440
principals.people.primaryNameprincipals/people/primaryNamestringJason Blum5,837,515
principals.people.primaryNameprincipals/people/primaryNamestringNeal H. Moritz5,834,656
principals.people.primaryNameprincipals/people/primaryNamestringRichard Francis-Bruce5,798,818
principals.people.primaryNameprincipals/people/primaryNamestringWillem Dafoe5,769,684
principals.people.primaryNameprincipals/people/primaryNamestringAkiva Goldsman5,752,462
principals.characters.valueprincipals/characters/valuestringNarrator5,720,979
principals.people.primaryNameprincipals/people/primaryNamestringFrank Darabont5,713,504
principals.people.primaryNameprincipals/people/primaryNamestringStephen McFeely5,699,459
principals.people.primaryNameprincipals/people/primaryNamestringChristopher Markus5,699,459
principals.people.primaryNameprincipals/people/primaryNamestringJoseph Gordon-Levitt5,674,867
principals.people.primaryNameprincipals/people/primaryNamestringMichael Bay5,670,145
principals.people.primaryNameprincipals/people/primaryNamestringSigourney Weaver5,665,390
principals.people.primaryNameprincipals/people/primaryNamestringClint Eastwood5,641,837
principals.people.primaryNameprincipals/people/primaryNamestringRyan Reynolds5,602,598
principals.people.primaryNameprincipals/people/primaryNamestringRalph Fiennes5,575,812
principals.people.primaryNameprincipals/people/primaryNamestringArnon Milchan5,557,076
principals.characters.valueprincipals/characters/valuestringFrodo5,556,178
principals.people.primaryNameprincipals/people/primaryNamestringAndrew Stanton5,524,664
principals.characters.valueprincipals/characters/valuestringLegolas5,521,522
principals.people.primaryNameprincipals/people/primaryNamestringJennifer Lawrence5,512,826
principals.people.primaryNameprincipals/people/primaryNamestringScott Rudin5,471,280
principals.people.primaryNameprincipals/people/primaryNamestringJake Gyllenhaal5,468,399
principals.people.primaryNameprincipals/people/primaryNamestringSimon Kinberg5,448,589
principals.people.primaryNameprincipals/people/primaryNamestringTom Hardy5,425,192
principals.characters.valueprincipals/characters/valuestringJack5,422,655
principals.people.primaryNameprincipals/people/primaryNamestringEmma Watson5,394,356
principals.people.primaryNameprincipals/people/primaryNamestringJonah Hill5,386,018
principals.people.primaryNameprincipals/people/primaryNamestringBen Kingsley5,381,627
principals.jobprincipals/jobstringoriginal story by5,380,885
principals.people.primaryNameprincipals/people/primaryNamestringTim Burton5,358,801
principals.people.primaryNameprincipals/people/primaryNamestringRussell Crowe5,349,512
principals.people.primaryNameprincipals/people/primaryNamestringAnthony Hopkins5,326,430
principals.people.primaryNameprincipals/people/primaryNamestringDenzel Washington5,321,895
principals.people.primaryNameprincipals/people/primaryNamestringCeán Chaffin5,242,896
principals.people.primaryNameprincipals/people/primaryNamestringJoaquin Phoenix5,229,143
principals.people.primaryNameprincipals/people/primaryNamestringAmy Adams5,222,095
principals.people.primaryNameprincipals/people/primaryNamestringVin Diesel5,220,720
genres.valuegenres/valuestringWestern5,174,672
principals.people.primaryNameprincipals/people/primaryNamestringRick McCallum5,131,088
principals.people.primaryNameprincipals/people/primaryNamestringSteve Kloves5,098,652
principals.people.primaryNameprincipals/people/primaryNamestringWoody Harrelson5,066,180
principals.people.primaryNameprincipals/people/primaryNamestringCarter Burwell5,061,592
principals.people.primaryNameprincipals/people/primaryNamestringDwayne Johnson5,042,701
genres.valuegenres/valuestringMusical5,029,814
principals.people.primaryNameprincipals/people/primaryNamestringViggo Mortensen5,026,908
principals.people.primaryNameprincipals/people/primaryNamestringTerry Rossio4,976,295
principals.people.primaryNameprincipals/people/primaryNamestringSteve Carell4,955,275
principals.people.primaryNameprincipals/people/primaryNamestringKathleen Kennedy4,913,452
principals.people.primaryNameprincipals/people/primaryNamestringTed Elliott4,910,223
principals.people.primaryNameprincipals/people/primaryNamestringKen Watanabe4,899,180
principals.people.primaryNameprincipals/people/primaryNamestringJ.K. Rowling4,897,178
principals.people.primaryNameprincipals/people/primaryNamestringLauren Shuler Donner4,882,527
principals.people.primaryNameprincipals/people/primaryNamestringUma Thurman4,841,627
principals.people.primaryNameprincipals/people/primaryNamestringJohn Travolta4,830,018
principals.people.primaryNameprincipals/people/primaryNamestringPaul Rudd4,815,940
principals.characters.valueprincipals/characters/valuestringCaptain America4,804,068
principals.people.primaryNameprincipals/people/primaryNamestringTodd Phillips4,803,847
principals.jobprincipals/jobstringcreator4,790,839
principals.people.primaryNameprincipals/people/primaryNamestringSeth Rogen4,747,549
principals.people.primaryNameprincipals/people/primaryNamestringAlexandre Desplat4,733,739
principals.people.primaryNameprincipals/people/primaryNamestringTim Robbins4,711,106
principals.people.primaryNameprincipals/people/primaryNamestringMarco Beltrami4,690,576
principals.people.primaryNameprincipals/people/primaryNamestringWill Ferrell4,685,531
principals.people.primaryNameprincipals/people/primaryNamestringStanley Kubrick4,677,865
principals.people.primaryNameprincipals/people/primaryNamestringMichael Giacchino4,655,719
principals.people.primaryNameprincipals/people/primaryNamestringAlan Silvestri4,652,513
principals.characters.valueprincipals/characters/valuestringMichael4,618,522
principals.people.primaryNameprincipals/people/primaryNamestringGeorge Clooney4,611,238
principals.jobprincipals/jobstringscreen story4,609,247
[
  {
    "fieldName": "averageRating",
    "fieldPath": "averageRating",
    "fieldType": "number",
    "fieldValue": "1.0 to 10.0",
    "weight": 714469771
  },
  {
    "fieldName": "endYear",
    "fieldPath": "endYear",
    "fieldType": "number",
    "fieldValue": "1964.0 to 2024.0",
    "weight": 714469771
  },
  {
    "fieldName": "isAdult",
    "fieldPath": "isAdult",
    "fieldType": "string",
    "fieldValue": "0",
    "weight": 714469771
  },
  {
    "fieldName": "numVotes",
    "fieldPath": "numVotes",
    "fieldType": "number",
    "fieldValue": "100038.0 to 2755400.0",
    "weight": 714469771
  },
  {
    "fieldName": "runtimeMinutes",
    "fieldPath": "runtimeMinutes",
    "fieldType": "number",
    "fieldValue": "100.0 to 780.0",
    "weight": 714469771
  },
  {
    "fieldName": "startYear",
    "fieldPath": "startYear",
    "fieldType": "number",
    "fieldValue": "1920.0 to 2023.0",
    "weight": 714469771
  },
  {
    "fieldName": null,
    "fieldPath": null,
    "fieldType": null,
    "fieldValue": null,
    "weight": 714469771
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "\\N",
    "weight": 710157083
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "actor",
    "weight": 701487296
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "\\N",
    "weight": 699848852
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "director",
    "weight": 620204196
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "writer",
    "weight": 607504744
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "actress",
    "weight": 602626378
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "producer",
    "weight": 537269065
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "producer",
    "weight": 535386766
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Drama",
    "weight": 359114628
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "composer",
    "weight": 312605800
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Action",
    "weight": 264226875
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "cinematographer",
    "weight": 224101431
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Adventure",
    "weight": 215611055
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Comedy",
    "weight": 212507003
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "screenplay",
    "weight": 177562290
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "director of photography",
    "weight": 168243129
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "written by",
    "weight": 165087869
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Crime",
    "weight": 145729251
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "editor",
    "weight": 132908043
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Thriller",
    "weight": 114203967
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "screenplay by",
    "weight": 104649227
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Sci-Fi",
    "weight": 90975508
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Mystery",
    "weight": 75660294
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Fantasy",
    "weight": 74967764
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Romance",
    "weight": 74817238
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Horror",
    "weight": 64058121
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "story",
    "weight": 57869437
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Animation",
    "weight": 55199540
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Biography",
    "weight": 47161526
  },
  {
    "fieldName": "principals.category",
    "fieldPath": "principals/category",
    "fieldType": "string",
    "fieldValue": "production_designer",
    "weight": 40349341
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "created by",
    "weight": 40026996
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "novel",
    "weight": 35861643
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "story by",
    "weight": 33261702
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Family",
    "weight": 29671871
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "characters",
    "weight": 26267654
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "History",
    "weight": 20121196
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "based on the novel by",
    "weight": 17698559
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Leonardo DiCaprio",
    "weight": 16129810
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Pitt",
    "weight": 15289297
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "book",
    "weight": 13755649
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Tom Hanks",
    "weight": 13142846
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "War",
    "weight": 13138049
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Christopher Nolan",
    "weight": 13112845
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Music",
    "weight": 12874450
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "film editor",
    "weight": 12309812
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Christian Bale",
    "weight": 12050004
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Robert De Niro",
    "weight": 12046334
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Samuel L. Jackson",
    "weight": 11809747
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "co-director",
    "weight": 11252962
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Quentin Tarantino",
    "weight": 11242958
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "John Williams",
    "weight": 10867148
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "based on characters created by",
    "weight": 10782925
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Stan Lee",
    "weight": 10444364
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Charles Roven",
    "weight": 10305308
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Sport",
    "weight": 10216137
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "developed by",
    "weight": 9945597
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ian McKellen",
    "weight": 9759427
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bob Kane",
    "weight": 9719269
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Steven Spielberg",
    "weight": 9687830
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batman",
    "weight": 9644754
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Thomas Newman",
    "weight": 9579153
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Tom Cruise",
    "weight": 9422729
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Johnny Depp",
    "weight": 9348470
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bruce Wayne",
    "weight": 9340134
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Morgan Freeman",
    "weight": 9187609
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Matt Damon",
    "weight": 9149079
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "David S. Goyer",
    "weight": 9085091
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "based on the Marvel comics by",
    "weight": 9055763
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Peter Jackson",
    "weight": 8906644
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Orlando Bloom",
    "weight": 8895876
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bruce Willis",
    "weight": 8711181
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Martin Scorsese",
    "weight": 8700354
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Cooper",
    "weight": 8425640
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Stephen King",
    "weight": 8376793
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Jonathan Nolan",
    "weight": 8343275
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Liam Neeson",
    "weight": 8209528
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Lawrence Bender",
    "weight": 8205607
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Michael Caine",
    "weight": 8183734
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Hans Zimmer",
    "weight": 8120419
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Emma Thomas",
    "weight": 8088224
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Fran Walsh",
    "weight": 7936766
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Philippa Boyens",
    "weight": 7770741
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "J.R.R. Tolkien",
    "weight": 7711979
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Robert Richardson",
    "weight": 7709024
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Gandalf",
    "weight": 7631041
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "George Lucas",
    "weight": 7585197
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "based on the book by",
    "weight": 7560659
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Jack Kirby",
    "weight": 7535566
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Lorne Orleans",
    "weight": 7371423
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "David Fincher",
    "weight": 7254941
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Sally Menke",
    "weight": 7239769
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Natalie Portman",
    "weight": 7173322
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Mark Ruffalo",
    "weight": 7156155
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Mark Wahlberg",
    "weight": 7152730
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ridley Scott",
    "weight": 6860931
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "James Horner",
    "weight": 6849235
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Edward Norton",
    "weight": 6729200
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Hugh Jackman",
    "weight": 6674864
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Al Pacino",
    "weight": 6660396
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Roger Deakins",
    "weight": 6610720
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brian Grazer",
    "weight": 6556669
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Anne Hathaway",
    "weight": 6555118
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Chris Evans",
    "weight": 6534707
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Elijah Wood",
    "weight": 6483293
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Jerry Bruckheimer",
    "weight": 6461054
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ben Affleck",
    "weight": 6453066
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Matthew McConaughey",
    "weight": 6445973
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Kevin Feige",
    "weight": 6443135
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Tim Bevan",
    "weight": 6428885
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Robert Downey Jr.",
    "weight": 6406323
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "David Heyman",
    "weight": 6374985
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Scarlett Johansson",
    "weight": 6298000
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Will Smith",
    "weight": 6271538
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Chris Hemsworth",
    "weight": 6215489
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "James Cameron",
    "weight": 6208367
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "James Newton Howard",
    "weight": 6099103
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Danny Elfman",
    "weight": 6068336
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Harrison Ford",
    "weight": 6033086
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Cate Blanchett",
    "weight": 5991509
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ewan McGregor",
    "weight": 5913545
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Mel Gibson",
    "weight": 5885534
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Robert Zemeckis",
    "weight": 5866737
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Pete Docter",
    "weight": 5862141
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Eric Fellner",
    "weight": 5838440
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Jason Blum",
    "weight": 5837515
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Neal H. Moritz",
    "weight": 5834656
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Richard Francis-Bruce",
    "weight": 5798818
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Willem Dafoe",
    "weight": 5769684
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Akiva Goldsman",
    "weight": 5752462
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Narrator",
    "weight": 5720979
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Frank Darabont",
    "weight": 5713504
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Stephen McFeely",
    "weight": 5699459
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Christopher Markus",
    "weight": 5699459
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Joseph Gordon-Levitt",
    "weight": 5674867
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Michael Bay",
    "weight": 5670145
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Sigourney Weaver",
    "weight": 5665390
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Clint Eastwood",
    "weight": 5641837
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ryan Reynolds",
    "weight": 5602598
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ralph Fiennes",
    "weight": 5575812
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Arnon Milchan",
    "weight": 5557076
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Frodo",
    "weight": 5556178
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Andrew Stanton",
    "weight": 5524664
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Legolas",
    "weight": 5521522
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Jennifer Lawrence",
    "weight": 5512826
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Scott Rudin",
    "weight": 5471280
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Jake Gyllenhaal",
    "weight": 5468399
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Simon Kinberg",
    "weight": 5448589
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Tom Hardy",
    "weight": 5425192
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Jack",
    "weight": 5422655
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Emma Watson",
    "weight": 5394356
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Jonah Hill",
    "weight": 5386018
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ben Kingsley",
    "weight": 5381627
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "original story by",
    "weight": 5380885
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Tim Burton",
    "weight": 5358801
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Russell Crowe",
    "weight": 5349512
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Anthony Hopkins",
    "weight": 5326430
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Denzel Washington",
    "weight": 5321895
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ceán Chaffin",
    "weight": 5242896
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Joaquin Phoenix",
    "weight": 5229143
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Amy Adams",
    "weight": 5222095
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Vin Diesel",
    "weight": 5220720
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Western",
    "weight": 5174672
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Rick McCallum",
    "weight": 5131088
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Steve Kloves",
    "weight": 5098652
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Woody Harrelson",
    "weight": 5066180
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Carter Burwell",
    "weight": 5061592
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Dwayne Johnson",
    "weight": 5042701
  },
  {
    "fieldName": "genres.value",
    "fieldPath": "genres/value",
    "fieldType": "string",
    "fieldValue": "Musical",
    "weight": 5029814
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Viggo Mortensen",
    "weight": 5026908
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Terry Rossio",
    "weight": 4976295
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Steve Carell",
    "weight": 4955275
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Kathleen Kennedy",
    "weight": 4913452
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ted Elliott",
    "weight": 4910223
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Ken Watanabe",
    "weight": 4899180
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "J.K. Rowling",
    "weight": 4897178
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Lauren Shuler Donner",
    "weight": 4882527
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Uma Thurman",
    "weight": 4841627
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "John Travolta",
    "weight": 4830018
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Paul Rudd",
    "weight": 4815940
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Captain America",
    "weight": 4804068
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Todd Phillips",
    "weight": 4803847
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "creator",
    "weight": 4790839
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Seth Rogen",
    "weight": 4747549
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Alexandre Desplat",
    "weight": 4733739
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Tim Robbins",
    "weight": 4711106
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Marco Beltrami",
    "weight": 4690576
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Will Ferrell",
    "weight": 4685531
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Stanley Kubrick",
    "weight": 4677865
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Michael Giacchino",
    "weight": 4655719
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Alan Silvestri",
    "weight": 4652513
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Michael",
    "weight": 4618522
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "George Clooney",
    "weight": 4611238
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "screen story",
    "weight": 4609247
  }
]
WITH __stage0 AS (
  SELECT * from (SELECT * FROM '../data/titles.parquet' USING SAMPLE 5000) as x limit 100000 )
, __stage1 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'averageRating'
      WHEN 1 THEN 'endYear'
      WHEN 2 THEN 'isAdult'
      WHEN 3 THEN 'numVotes'
      WHEN 4 THEN 'originalTitle'
      WHEN 5 THEN 'primaryTitle'
      WHEN 6 THEN 'runtimeMinutes'
      WHEN 7 THEN 'startYear'
      WHEN 8 THEN 'tconst'
      WHEN 9 THEN 'genres.value'
      WHEN 10 THEN 'principals.category'
      WHEN 11 THEN 'principals.job'
      WHEN 12 THEN 'principals.characters.value'
      WHEN 13 THEN 'principals.people.primaryName'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'averageRating'
      WHEN 1 THEN 'endYear'
      WHEN 2 THEN 'isAdult'
      WHEN 3 THEN 'numVotes'
      WHEN 4 THEN 'originalTitle'
      WHEN 5 THEN 'primaryTitle'
      WHEN 6 THEN 'runtimeMinutes'
      WHEN 7 THEN 'startYear'
      WHEN 8 THEN 'tconst'
      WHEN 9 THEN 'genres/value'
      WHEN 10 THEN 'principals/category'
      WHEN 11 THEN 'principals/job'
      WHEN 12 THEN 'principals/characters/value'
      WHEN 13 THEN 'principals/people/primaryName'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'number'
      WHEN 1 THEN 'number'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'number'
      WHEN 4 THEN 'string'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'number'
      WHEN 7 THEN 'number'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'string'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 2 THEN movies."isAdult"
      WHEN 4 THEN movies."originalTitle"
      WHEN 5 THEN movies."primaryTitle"
      WHEN 8 THEN movies."tconst"
      WHEN 9 THEN genres_0
      WHEN 10 THEN principals_0."category"
      WHEN 11 THEN principals_0."job"
      WHEN 12 THEN characters_0
      WHEN 13 THEN people_0."primaryName"
    END as "fieldValue",
   COALESCE((
        SELECT SUM(a.val) as value
        FROM (
          SELECT UNNEST(list(distinct {key:movies."__distinct_key", val: movies."numVotes"})) a
        )
      ),0) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 0 THEN MIN(CAST(movies."averageRating" as VARCHAR)) || ' to ' || CAST(MAX(movies."averageRating") as VARCHAR)
      WHEN 1 THEN MIN(CAST(movies."endYear" as VARCHAR)) || ' to ' || CAST(MAX(movies."endYear") as VARCHAR)
      WHEN 3 THEN MIN(CAST(movies."numVotes" as VARCHAR)) || ' to ' || CAST(MAX(movies."numVotes") as VARCHAR)
      WHEN 6 THEN MIN(CAST(movies."runtimeMinutes" as VARCHAR)) || ' to ' || CAST(MAX(movies."runtimeMinutes") as VARCHAR)
      WHEN 7 THEN MIN(CAST(movies."startYear" as VARCHAR)) || ' to ' || CAST(MAX(movies."startYear") as VARCHAR)
    END as "fieldRange"
  FROM (SELECT GEN_RANDOM_UUID() as __distinct_key, x.*  FROM __stage0 as x) as movies
  LEFT JOIN LATERAL (SELECT UNNEST(movies."genres"), 1 as ignoreme) as genres_0_outer(genres_0,ignoreme) ON genres_0_outer.ignoreme=1
   LEFT JOIN '../data/principals.parquet' AS principals_0
    ON movies."tconst"=principals_0."tconst"
  LEFT JOIN LATERAL (SELECT UNNEST(principals_0."characters"), 1 as ignoreme) as characters_0_outer(characters_0,ignoreme) ON characters_0_outer.ignoreme=1
   LEFT JOIN '../data/names.parquet' AS people_0
    ON principals_0."nconst"=people_0."nconst"
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,14,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
, __stage2 AS (
  SELECT
    "fieldName",
    "fieldPath",
    "fieldType",
    COALESCE("fieldValue", "fieldRange") as "fieldValue",
    weight
  FROM __stage1
)
SELECT 
   base."fieldName" as "fieldName",
   base."fieldPath" as "fieldPath",
   base."fieldType" as "fieldType",
   base."fieldValue" as "fieldValue",
   base."weight" as "weight"
FROM __stage2 as base
ORDER BY 5 desc NULLS LAST

Search Index Naming Convention

By convention indexes in sources are named search_index.

document
source: movies2 is duckdb.table('../data/titles.parquet') extend {
  join_many: principals is duckdb.table('../data/principals.parquet') extend {
    join_one: people is duckdb.table('../data/names.parquet') 
      on nconst = people.nconst
  } on tconst = principals.tconst

  measure: total_ratings is numVotes.sum()

  view: search_index is {
    index:
      *
      genres.*
      principals.category, principals.job
      principals.characters.*
      principals.people.primaryName
    by total_ratings
  }
}

So to look for 'Brad'

document
run: movies2 -> search_index -> { 
  select: *
  where: fieldValue ~ 'Brad%'
  order_by: weight desc
}
QUERY RESULTS
fieldNamefieldPathfieldTypefieldValueweight
principals.people.primaryNameprincipals/people/primaryNamestringBrad Pitt18,269,386
principals.people.primaryNameprincipals/people/primaryNamestringBradley Cooper8,980,668
principals.people.primaryNameprincipals/people/primaryNamestringBrad Bird2,783,448
principals.people.primaryNameprincipals/people/primaryNamestringBradley J. Fischer2,582,567
principals.people.primaryNameprincipals/people/primaryNamestringBrad Fiedel2,516,157
principals.people.primaryNameprincipals/people/primaryNamestringBrad Grey1,858,689
principals.people.primaryNameprincipals/people/primaryNamestringBrad Fuller1,589,845
principals.people.primaryNameprincipals/people/primaryNamestringBrad Garrett989,180
principals.people.primaryNameprincipals/people/primaryNamestringBradley Whitford908,639
principals.people.primaryNameprincipals/people/primaryNamestringBrad Anderson785,214
principals.people.primaryNameprincipals/people/primaryNamestringBradley Thomas672,907
principals.people.primaryNameprincipals/people/primaryNamestringBrad Dourif595,034
principals.people.primaryNameprincipals/people/primaryNamestringBrad Falchuk594,475
principals.people.primaryNameprincipals/people/primaryNamestringBrad Krevoy593,257
principals.people.primaryNameprincipals/people/primaryNamestringBradford Lewis566,153
principals.people.primaryNameprincipals/people/primaryNamestringBrad Peyton565,084
principals.characters.valueprincipals/characters/valuestringBrad Bellick553,782
principals.people.primaryNameprincipals/people/primaryNamestringBrad Silberling552,092
principals.characters.valueprincipals/characters/valuestringBrad Gurdlinger466,826
principals.people.primaryNameprincipals/people/primaryNamestringBrad Ingelsby452,543
principals.people.primaryNameprincipals/people/primaryNamestringBrad Segal402,692
principals.people.primaryNameprincipals/people/primaryNamestringBrad Furman385,968
principals.people.primaryNameprincipals/people/primaryNamestringBrad Mann384,595
principals.people.primaryNameprincipals/people/primaryNamestringBraden Aftergood374,772
principals.people.primaryNameprincipals/people/primaryNamestringBrad Winderbaum366,995
principals.people.primaryNameprincipals/people/primaryNamestringBrad Swaile345,759
principals.people.primaryNameprincipals/people/primaryNamestringBrad Wright278,557
principals.people.primaryNameprincipals/people/primaryNamestringBrad Renfro273,848
principals.characters.valueprincipals/characters/valuestringBradley Fine250,952
principals.people.primaryNameprincipals/people/primaryNamestringBrad Greenquist250,909
principals.characters.valueprincipals/characters/valuestringBrad245,925
principals.people.primaryNameprincipals/people/primaryNamestringBrad Copeland234,415
principals.characters.valueprincipals/characters/valuestringBrad Whitaker226,799
principals.people.primaryNameprincipals/people/primaryNamestringBrad Epstein197,059
principals.people.primaryNameprincipals/people/primaryNamestringBradley Gallo184,654
principals.people.primaryNameprincipals/people/primaryNamestringBrady Corbet173,307
principals.characters.valueprincipals/characters/valuestringBrad Majors - A Hero158,457
principals.people.primaryNameprincipals/people/primaryNamestringBrad Wyman156,357
principals.people.primaryNameprincipals/people/primaryNamestringBrad Davis150,273
principals.people.primaryNameprincipals/people/primaryNamestringBradford Dillman131,412
principals.characters.valueprincipals/characters/valuestringBrad Adamson113,849
principals.characters.valueprincipals/characters/valuestringBradley Martin112,103
principals.characters.valueprincipals/characters/valuestringBradley Jackson110,209
principals.characters.valueprincipals/characters/valuestringBrad Hamilton110,039
principals.people.primaryNameprincipals/people/primaryNamestringBrad Kane86,923
principals.people.primaryNameprincipals/people/primaryNamestringBrad Halvorson85,643
principals.people.primaryNameprincipals/people/primaryNamestringBradley James84,478
principals.characters.valueprincipals/characters/valuestringBrad Cage82,655
principals.characters.valueprincipals/characters/valuestringBrad Wesley80,561
principals.people.primaryNameprincipals/people/primaryNamestringBradford Lipson78,284
principals.people.primaryNameprincipals/people/primaryNamestringBrady Noon77,389
principals.people.primaryNameprincipals/people/primaryNamestringBrad Ableson75,588
principals.people.primaryNameprincipals/people/primaryNamestringBradford Young75,006
principals.people.primaryNameprincipals/people/primaryNamestringBrad Booker74,354
principals.people.primaryNameprincipals/people/primaryNamestringBrad Riddell73,922
principals.people.primaryNameprincipals/people/primaryNamestringBrad Gann73,337
principals.people.primaryNameprincipals/people/primaryNamestringBradley Stonesifer71,122
principals.characters.valueprincipals/characters/valuestringBradley Thomas71,027
principals.people.primaryNameprincipals/people/primaryNamestringBrad Leland69,259
principals.characters.valueprincipals/characters/valuestringBrad Lewis68,518
principals.characters.valueprincipals/characters/valuestringBrad Gregory67,955
principals.people.primaryNameprincipals/people/primaryNamestringBradley Parker67,355
principals.characters.valueprincipals/characters/valuestringBrad Stand65,526
principals.characters.valueprincipals/characters/valuestringBrad (segment \Tape 56\)65,431
principals.people.primaryNameprincipals/people/primaryNamestringBrady Coleman61,797
principals.characters.valueprincipals/characters/valuestringBrad Chang59,267
principals.people.primaryNameprincipals/people/primaryNamestringBrad Beyer57,584
principals.people.primaryNameprincipals/people/primaryNamestringBrad Weston51,673
principals.characters.valueprincipals/characters/valuestringBrad Bottig51,451
principals.characters.valueprincipals/characters/valuestringBrad Chase48,224
principals.people.primaryNameprincipals/people/primaryNamestringBradley King47,442
principals.people.primaryNameprincipals/people/primaryNamestringBrad Loree46,958
principals.characters.valueprincipals/characters/valuestringBrad Harris46,640
principals.people.primaryNameprincipals/people/primaryNamestringBrad Morris46,105
principals.characters.valueprincipals/characters/valuestringBrad Taylor46,084
principals.people.primaryNameprincipals/people/primaryNamestringBradley Raymond43,731
principals.people.primaryNameprincipals/people/primaryNamestringBradley Jenkel42,784
principals.people.primaryNameprincipals/people/primaryNamestringBrad M. Gilbert39,777
principals.people.primaryNameprincipals/people/primaryNamestringBrad Baruh39,491
principals.characters.valueprincipals/characters/valuestringBrad Williams39,300
principals.characters.valueprincipals/characters/valuestringBradley38,412
principals.characters.valueprincipals/characters/valuestringBrad Brown37,424
principals.people.primaryNameprincipals/people/primaryNamestringBradford L. Schlei35,007
principals.people.primaryNameprincipals/people/primaryNamestringBrad Silverman34,490
principals.people.primaryNameprincipals/people/primaryNamestringBrad Simpson33,880
principals.people.primaryNameprincipals/people/primaryNamestringBradford May33,729
principals.people.primaryNameprincipals/people/primaryNamestringBrad Johnson31,763
[
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Pitt",
    "weight": 18269386
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Cooper",
    "weight": 8980668
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Bird",
    "weight": 2783448
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley J. Fischer",
    "weight": 2582567
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Fiedel",
    "weight": 2516157
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Grey",
    "weight": 1858689
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Fuller",
    "weight": 1589845
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Garrett",
    "weight": 989180
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Whitford",
    "weight": 908639
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Anderson",
    "weight": 785214
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Thomas",
    "weight": 672907
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Dourif",
    "weight": 595034
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Falchuk",
    "weight": 594475
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Krevoy",
    "weight": 593257
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradford Lewis",
    "weight": 566153
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Peyton",
    "weight": 565084
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Bellick",
    "weight": 553782
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Silberling",
    "weight": 552092
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Gurdlinger",
    "weight": 466826
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Ingelsby",
    "weight": 452543
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Segal",
    "weight": 402692
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Furman",
    "weight": 385968
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Mann",
    "weight": 384595
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Braden Aftergood",
    "weight": 374772
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Winderbaum",
    "weight": 366995
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Swaile",
    "weight": 345759
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Wright",
    "weight": 278557
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Renfro",
    "weight": 273848
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bradley Fine",
    "weight": 250952
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Greenquist",
    "weight": 250909
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad",
    "weight": 245925
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Copeland",
    "weight": 234415
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Whitaker",
    "weight": 226799
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Epstein",
    "weight": 197059
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Gallo",
    "weight": 184654
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brady Corbet",
    "weight": 173307
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Majors - A Hero",
    "weight": 158457
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Wyman",
    "weight": 156357
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Davis",
    "weight": 150273
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradford Dillman",
    "weight": 131412
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Adamson",
    "weight": 113849
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bradley Martin",
    "weight": 112103
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bradley Jackson",
    "weight": 110209
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Hamilton",
    "weight": 110039
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Kane",
    "weight": 86923
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Halvorson",
    "weight": 85643
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley James",
    "weight": 84478
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Cage",
    "weight": 82655
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Wesley",
    "weight": 80561
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradford Lipson",
    "weight": 78284
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brady Noon",
    "weight": 77389
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Ableson",
    "weight": 75588
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradford Young",
    "weight": 75006
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Booker",
    "weight": 74354
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Riddell",
    "weight": 73922
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Gann",
    "weight": 73337
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Stonesifer",
    "weight": 71122
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bradley Thomas",
    "weight": 71027
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Leland",
    "weight": 69259
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Lewis",
    "weight": 68518
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Gregory",
    "weight": 67955
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Parker",
    "weight": 67355
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Stand",
    "weight": 65526
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad (segment \\Tape 56\\)",
    "weight": 65431
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brady Coleman",
    "weight": 61797
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Chang",
    "weight": 59267
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Beyer",
    "weight": 57584
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Weston",
    "weight": 51673
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Bottig",
    "weight": 51451
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Chase",
    "weight": 48224
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley King",
    "weight": 47442
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Loree",
    "weight": 46958
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Harris",
    "weight": 46640
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Morris",
    "weight": 46105
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Taylor",
    "weight": 46084
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Raymond",
    "weight": 43731
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradley Jenkel",
    "weight": 42784
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad M. Gilbert",
    "weight": 39777
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Baruh",
    "weight": 39491
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Williams",
    "weight": 39300
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bradley",
    "weight": 38412
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Brad Brown",
    "weight": 37424
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradford L. Schlei",
    "weight": 35007
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Silverman",
    "weight": 34490
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Simpson",
    "weight": 33880
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bradford May",
    "weight": 33729
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Brad Johnson",
    "weight": 31763
  }
]
WITH __stage0 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'averageRating'
      WHEN 1 THEN 'endYear'
      WHEN 2 THEN 'isAdult'
      WHEN 3 THEN 'numVotes'
      WHEN 4 THEN 'originalTitle'
      WHEN 5 THEN 'primaryTitle'
      WHEN 6 THEN 'runtimeMinutes'
      WHEN 7 THEN 'startYear'
      WHEN 8 THEN 'tconst'
      WHEN 9 THEN 'genres.value'
      WHEN 10 THEN 'principals.category'
      WHEN 11 THEN 'principals.job'
      WHEN 12 THEN 'principals.characters.value'
      WHEN 13 THEN 'principals.people.primaryName'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'averageRating'
      WHEN 1 THEN 'endYear'
      WHEN 2 THEN 'isAdult'
      WHEN 3 THEN 'numVotes'
      WHEN 4 THEN 'originalTitle'
      WHEN 5 THEN 'primaryTitle'
      WHEN 6 THEN 'runtimeMinutes'
      WHEN 7 THEN 'startYear'
      WHEN 8 THEN 'tconst'
      WHEN 9 THEN 'genres/value'
      WHEN 10 THEN 'principals/category'
      WHEN 11 THEN 'principals/job'
      WHEN 12 THEN 'principals/characters/value'
      WHEN 13 THEN 'principals/people/primaryName'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'number'
      WHEN 1 THEN 'number'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'number'
      WHEN 4 THEN 'string'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'number'
      WHEN 7 THEN 'number'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'string'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 2 THEN movies2."isAdult"
      WHEN 4 THEN movies2."originalTitle"
      WHEN 5 THEN movies2."primaryTitle"
      WHEN 8 THEN movies2."tconst"
      WHEN 9 THEN genres_0
      WHEN 10 THEN principals_0."category"
      WHEN 11 THEN principals_0."job"
      WHEN 12 THEN characters_0
      WHEN 13 THEN people_0."primaryName"
    END as "fieldValue",
   COALESCE((
        SELECT SUM(a.val) as value
        FROM (
          SELECT UNNEST(list(distinct {key:movies2."__distinct_key", val: movies2."numVotes"})) a
        )
      ),0) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 0 THEN MIN(CAST(movies2."averageRating" as VARCHAR)) || ' to ' || CAST(MAX(movies2."averageRating") as VARCHAR)
      WHEN 1 THEN MIN(CAST(movies2."endYear" as VARCHAR)) || ' to ' || CAST(MAX(movies2."endYear") as VARCHAR)
      WHEN 3 THEN MIN(CAST(movies2."numVotes" as VARCHAR)) || ' to ' || CAST(MAX(movies2."numVotes") as VARCHAR)
      WHEN 6 THEN MIN(CAST(movies2."runtimeMinutes" as VARCHAR)) || ' to ' || CAST(MAX(movies2."runtimeMinutes") as VARCHAR)
      WHEN 7 THEN MIN(CAST(movies2."startYear" as VARCHAR)) || ' to ' || CAST(MAX(movies2."startYear") as VARCHAR)
    END as "fieldRange"
  FROM (SELECT GEN_RANDOM_UUID() as __distinct_key, x.*  FROM '../data/titles.parquet' as x) as movies2
  LEFT JOIN LATERAL (SELECT UNNEST(movies2."genres"), 1 as ignoreme) as genres_0_outer(genres_0,ignoreme) ON genres_0_outer.ignoreme=1
   LEFT JOIN '../data/principals.parquet' AS principals_0
    ON movies2."tconst"=principals_0."tconst"
  LEFT JOIN LATERAL (SELECT UNNEST(principals_0."characters"), 1 as ignoreme) as characters_0_outer(characters_0,ignoreme) ON characters_0_outer.ignoreme=1
   LEFT JOIN '../data/names.parquet' AS people_0
    ON principals_0."nconst"=people_0."nconst"
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,14,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
, __stage1 AS (
  SELECT
    "fieldName",
    "fieldPath",
    "fieldType",
    COALESCE("fieldValue", "fieldRange") as "fieldValue",
    weight
  FROM __stage0
)
SELECT 
   base."fieldName" as "fieldName",
   base."fieldPath" as "fieldPath",
   base."fieldType" as "fieldType",
   base."fieldValue" as "fieldValue",
   base."weight" as "weight"
FROM __stage1 as base
WHERE base."fieldValue" LIKE 'Brad%'
ORDER BY 5 desc NULLS LAST

So to look for 'Bat'

document
run: movies2 -> search_index -> { 
  select: *
  where: fieldValue ~ 'Bat%'
  order_by: weight desc
}
QUERY RESULTS
fieldNamefieldPathfieldTypefieldValueweight
principals.characters.valueprincipals/characters/valuestringBatman10,424,082
primaryTitleprimaryTitlestringBatman Begins1,507,854
originalTitleoriginalTitlestringBatman Begins1,507,854
principals.jobprincipals/jobstringBatman created by1,020,989
principals.jobprincipals/jobstringBatman characters964,899
principals.characters.valueprincipals/characters/valuestringBatty790,162
originalTitleoriginalTitlestringBatman v Superman: Dawn of Justice713,914
primaryTitleprimaryTitlestringBatman v Superman: Dawn of Justice713,914
primaryTitleprimaryTitlestringBatman389,337
originalTitleoriginalTitlestringBatman389,337
originalTitleoriginalTitlestringBatman Returns315,132
primaryTitleprimaryTitlestringBatman Returns315,132
principals.characters.valueprincipals/characters/valuestringBatou260,600
primaryTitleprimaryTitlestringBatman & Robin260,430
originalTitleoriginalTitlestringBatman & Robin260,430
originalTitleoriginalTitlestringBatman Forever259,315
primaryTitleprimaryTitlestringBatman Forever259,315
primaryTitleprimaryTitlestringBattleship252,642
originalTitleoriginalTitlestringBattleship252,642
primaryTitleprimaryTitlestringBattlestar Galactica248,435
originalTitleoriginalTitlestringBattlestar Galactica248,435
principals.characters.valueprincipals/characters/valuestringBatgirl221,004
originalTitleoriginalTitlestringBattle of the Bastards217,000
primaryTitleprimaryTitlestringBattle of the Bastards217,000
originalTitleoriginalTitlestringBatoru rowaiaru188,692
primaryTitleprimaryTitlestringBattle Royale188,692
originalTitleoriginalTitlestringBattle: Los Angeles182,720
primaryTitleprimaryTitlestringBattle Los Angeles182,720
principals.characters.valueprincipals/characters/valuestringBatô148,975
principals.characters.valueprincipals/characters/valuestringBatiatus141,304
principals.characters.valueprincipals/characters/valuestringBattera112,813
primaryTitleprimaryTitlestringBates Motel112,103
originalTitleoriginalTitlestringBates Motel112,103
primaryTitleprimaryTitlestringBatman: The Animated Series109,143
originalTitleoriginalTitlestringBatman: The Animated Series109,143
principals.characters.valueprincipals/characters/valuestringBattle Droids107,847
originalTitleoriginalTitlestringBattlefield Earth81,723
primaryTitleprimaryTitlestringBattlefield Earth81,723
principals.people.primaryNameprincipals/people/primaryNamestringBathsheba Doran76,412
principals.people.primaryNameprincipals/people/primaryNamestringBate Khalil73,385
primaryTitleprimaryTitlestringBatman v Superman: Dawn of Justice (Ultimate Edition)68,865
originalTitleoriginalTitlestringBatman v Superman: Dawn of Justice (Ultimate Edition)68,865
originalTitleoriginalTitlestringBatman: Under the Red Hood65,192
primaryTitleprimaryTitlestringBatman: Under the Red Hood65,192
originalTitleoriginalTitlestringBatman: The Dark Knight Returns, Part 161,312
primaryTitleprimaryTitlestringBatman: The Dark Knight Returns, Part 161,312
primaryTitleprimaryTitlestringBattleship Potemkin59,629
primaryTitleprimaryTitlestringBatman: The Killing Joke59,389
originalTitleoriginalTitlestringBatman: The Killing Joke59,389
originalTitleoriginalTitlestringBattle of the Sexes57,648
primaryTitleprimaryTitlestringBattle of the Sexes57,648
principals.characters.valueprincipals/characters/valuestringBathurst 202055,709
primaryTitleprimaryTitlestringBatman: The Dark Knight Returns, Part 253,960
originalTitleoriginalTitlestringBatman: The Dark Knight Returns, Part 253,960
primaryTitleprimaryTitlestringBatman: Mask of the Phantasm53,743
originalTitleoriginalTitlestringBatman: Mask of the Phantasm53,743
principals.characters.valueprincipals/characters/valuestringBatu51,728
principals.characters.valueprincipals/characters/valuestringBathsheba Everdene51,291
originalTitleoriginalTitlestringBatwoman45,279
principals.characters.valueprincipals/characters/valuestringBatwoman45,279
primaryTitleprimaryTitlestringBatwoman45,279
principals.characters.valueprincipals/characters/valuestringBatwing45,279
principals.characters.valueprincipals/characters/valuestringBatukeshwar 'Bittu' Tiwari41,416
primaryTitleprimaryTitlestringBatman: Year One36,891
originalTitleoriginalTitlestringBatman: Year One36,891
primaryTitleprimaryTitlestringBatman: Assault on Arkham36,460
originalTitleoriginalTitlestringBatman: Assault on Arkham36,460
principals.characters.valueprincipals/characters/valuestringBattal35,502
primaryTitleprimaryTitlestringBatman: The Movie34,606
originalTitleoriginalTitlestringBatman: The Movie34,606
principals.people.primaryNameprincipals/people/primaryNamestringBattle Davis33,046
principals.characters.valueprincipals/characters/valuestringBathroom Attendant33,012
primaryTitleprimaryTitlestringBatman: Arkham City32,852
originalTitleoriginalTitlestringBatman: Arkham City32,852
originalTitleoriginalTitlestringBattle for the Planet of the Apes32,287
primaryTitleprimaryTitlestringBattle for the Planet of the Apes32,287
principals.characters.valueprincipals/characters/valuestringBatty Koda32,170
[
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batman",
    "weight": 10424082
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman Begins",
    "weight": 1507854
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman Begins",
    "weight": 1507854
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "Batman created by",
    "weight": 1020989
  },
  {
    "fieldName": "principals.job",
    "fieldPath": "principals/job",
    "fieldType": "string",
    "fieldValue": "Batman characters",
    "weight": 964899
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batty",
    "weight": 790162
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman v Superman: Dawn of Justice",
    "weight": 713914
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman v Superman: Dawn of Justice",
    "weight": 713914
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman",
    "weight": 389337
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman",
    "weight": 389337
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman Returns",
    "weight": 315132
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman Returns",
    "weight": 315132
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batou",
    "weight": 260600
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman & Robin",
    "weight": 260430
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman & Robin",
    "weight": 260430
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman Forever",
    "weight": 259315
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman Forever",
    "weight": 259315
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battleship",
    "weight": 252642
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Battleship",
    "weight": 252642
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battlestar Galactica",
    "weight": 248435
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Battlestar Galactica",
    "weight": 248435
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batgirl",
    "weight": 221004
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Battle of the Bastards",
    "weight": 217000
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battle of the Bastards",
    "weight": 217000
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batoru rowaiaru",
    "weight": 188692
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battle Royale",
    "weight": 188692
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Battle: Los Angeles",
    "weight": 182720
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battle Los Angeles",
    "weight": 182720
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batô",
    "weight": 148975
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batiatus",
    "weight": 141304
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Battera",
    "weight": 112813
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Bates Motel",
    "weight": 112103
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Bates Motel",
    "weight": 112103
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Animated Series",
    "weight": 109143
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Animated Series",
    "weight": 109143
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Battle Droids",
    "weight": 107847
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Battlefield Earth",
    "weight": 81723
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battlefield Earth",
    "weight": 81723
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bathsheba Doran",
    "weight": 76412
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Bate Khalil",
    "weight": 73385
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman v Superman: Dawn of Justice (Ultimate Edition)",
    "weight": 68865
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman v Superman: Dawn of Justice (Ultimate Edition)",
    "weight": 68865
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Under the Red Hood",
    "weight": 65192
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Under the Red Hood",
    "weight": 65192
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Dark Knight Returns, Part 1",
    "weight": 61312
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Dark Knight Returns, Part 1",
    "weight": 61312
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battleship Potemkin",
    "weight": 59629
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Killing Joke",
    "weight": 59389
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Killing Joke",
    "weight": 59389
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Battle of the Sexes",
    "weight": 57648
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battle of the Sexes",
    "weight": 57648
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bathurst 2020",
    "weight": 55709
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Dark Knight Returns, Part 2",
    "weight": 53960
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Dark Knight Returns, Part 2",
    "weight": 53960
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Mask of the Phantasm",
    "weight": 53743
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Mask of the Phantasm",
    "weight": 53743
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batu",
    "weight": 51728
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bathsheba Everdene",
    "weight": 51291
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batwoman",
    "weight": 45279
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batwoman",
    "weight": 45279
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batwoman",
    "weight": 45279
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batwing",
    "weight": 45279
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batukeshwar 'Bittu' Tiwari",
    "weight": 41416
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Year One",
    "weight": 36891
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Year One",
    "weight": 36891
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Assault on Arkham",
    "weight": 36460
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Assault on Arkham",
    "weight": 36460
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Battal",
    "weight": 35502
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Movie",
    "weight": 34606
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: The Movie",
    "weight": 34606
  },
  {
    "fieldName": "principals.people.primaryName",
    "fieldPath": "principals/people/primaryName",
    "fieldType": "string",
    "fieldValue": "Battle Davis",
    "weight": 33046
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Bathroom Attendant",
    "weight": 33012
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Arkham City",
    "weight": 32852
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Batman: Arkham City",
    "weight": 32852
  },
  {
    "fieldName": "originalTitle",
    "fieldPath": "originalTitle",
    "fieldType": "string",
    "fieldValue": "Battle for the Planet of the Apes",
    "weight": 32287
  },
  {
    "fieldName": "primaryTitle",
    "fieldPath": "primaryTitle",
    "fieldType": "string",
    "fieldValue": "Battle for the Planet of the Apes",
    "weight": 32287
  },
  {
    "fieldName": "principals.characters.value",
    "fieldPath": "principals/characters/value",
    "fieldType": "string",
    "fieldValue": "Batty Koda",
    "weight": 32170
  }
]
WITH __stage0 AS (
  SELECT
    group_set,
    CASE group_set
      WHEN 0 THEN 'averageRating'
      WHEN 1 THEN 'endYear'
      WHEN 2 THEN 'isAdult'
      WHEN 3 THEN 'numVotes'
      WHEN 4 THEN 'originalTitle'
      WHEN 5 THEN 'primaryTitle'
      WHEN 6 THEN 'runtimeMinutes'
      WHEN 7 THEN 'startYear'
      WHEN 8 THEN 'tconst'
      WHEN 9 THEN 'genres.value'
      WHEN 10 THEN 'principals.category'
      WHEN 11 THEN 'principals.job'
      WHEN 12 THEN 'principals.characters.value'
      WHEN 13 THEN 'principals.people.primaryName'
    END as "fieldName",
    CASE group_set
      WHEN 0 THEN 'averageRating'
      WHEN 1 THEN 'endYear'
      WHEN 2 THEN 'isAdult'
      WHEN 3 THEN 'numVotes'
      WHEN 4 THEN 'originalTitle'
      WHEN 5 THEN 'primaryTitle'
      WHEN 6 THEN 'runtimeMinutes'
      WHEN 7 THEN 'startYear'
      WHEN 8 THEN 'tconst'
      WHEN 9 THEN 'genres/value'
      WHEN 10 THEN 'principals/category'
      WHEN 11 THEN 'principals/job'
      WHEN 12 THEN 'principals/characters/value'
      WHEN 13 THEN 'principals/people/primaryName'
    END as "fieldPath",
    CASE group_set
      WHEN 0 THEN 'number'
      WHEN 1 THEN 'number'
      WHEN 2 THEN 'string'
      WHEN 3 THEN 'number'
      WHEN 4 THEN 'string'
      WHEN 5 THEN 'string'
      WHEN 6 THEN 'number'
      WHEN 7 THEN 'number'
      WHEN 8 THEN 'string'
      WHEN 9 THEN 'string'
      WHEN 10 THEN 'string'
      WHEN 11 THEN 'string'
      WHEN 12 THEN 'string'
      WHEN 13 THEN 'string'
    END as "fieldType",  CASE group_set WHEN 99999 THEN CAST(NULL as VARCHAR)
      WHEN 2 THEN movies2."isAdult"
      WHEN 4 THEN movies2."originalTitle"
      WHEN 5 THEN movies2."primaryTitle"
      WHEN 8 THEN movies2."tconst"
      WHEN 9 THEN genres_0
      WHEN 10 THEN principals_0."category"
      WHEN 11 THEN principals_0."job"
      WHEN 12 THEN characters_0
      WHEN 13 THEN people_0."primaryName"
    END as "fieldValue",
   COALESCE((
        SELECT SUM(a.val) as value
        FROM (
          SELECT UNNEST(list(distinct {key:movies2."__distinct_key", val: movies2."numVotes"})) a
        )
      ),0) as weight,
    CASE group_set
      WHEN 99999 THEN ''    WHEN 0 THEN MIN(CAST(movies2."averageRating" as VARCHAR)) || ' to ' || CAST(MAX(movies2."averageRating") as VARCHAR)
      WHEN 1 THEN MIN(CAST(movies2."endYear" as VARCHAR)) || ' to ' || CAST(MAX(movies2."endYear") as VARCHAR)
      WHEN 3 THEN MIN(CAST(movies2."numVotes" as VARCHAR)) || ' to ' || CAST(MAX(movies2."numVotes") as VARCHAR)
      WHEN 6 THEN MIN(CAST(movies2."runtimeMinutes" as VARCHAR)) || ' to ' || CAST(MAX(movies2."runtimeMinutes") as VARCHAR)
      WHEN 7 THEN MIN(CAST(movies2."startYear" as VARCHAR)) || ' to ' || CAST(MAX(movies2."startYear") as VARCHAR)
    END as "fieldRange"
  FROM (SELECT GEN_RANDOM_UUID() as __distinct_key, x.*  FROM '../data/titles.parquet' as x) as movies2
  LEFT JOIN LATERAL (SELECT UNNEST(movies2."genres"), 1 as ignoreme) as genres_0_outer(genres_0,ignoreme) ON genres_0_outer.ignoreme=1
   LEFT JOIN '../data/principals.parquet' AS principals_0
    ON movies2."tconst"=principals_0."tconst"
  LEFT JOIN LATERAL (SELECT UNNEST(principals_0."characters"), 1 as ignoreme) as characters_0_outer(characters_0,ignoreme) ON characters_0_outer.ignoreme=1
   LEFT JOIN '../data/names.parquet' AS people_0
    ON principals_0."nconst"=people_0."nconst"
  CROSS JOIN (SELECT UNNEST(GENERATE_SERIES(0,14,1)) as group_set  ) as group_set
  GROUP BY 1,2,3,4,5
)
, __stage1 AS (
  SELECT
    "fieldName",
    "fieldPath",
    "fieldType",
    COALESCE("fieldValue", "fieldRange") as "fieldValue",
    weight
  FROM __stage0
)
SELECT 
   base."fieldName" as "fieldName",
   base."fieldPath" as "fieldPath",
   base."fieldType" as "fieldType",
   base."fieldValue" as "fieldValue",
   base."weight" as "weight"
FROM __stage1 as base
WHERE base."fieldValue" LIKE 'Bat%'
ORDER BY 5 desc NULLS LAST