SET SQL_SAFE_UPDATES = 0;

INSERT INTO category_criteria (node_id, KeywordCriteria)
SELECT 
    js.category_id,
    '{
  "name": "FanKeywordSearchSchema",
  "description": "Schema for categorizing fan-related search keywords with boolean flags, specific values, and contextual descriptions",
  "schema": {
    "type": "object",
    "properties": {
      "brand": {
        "type": "object",
        "properties": {
          "is_mentioned": {
            "type": "boolean",
            "description": "Indicates whether a specific brand is mentioned in the search query"
          },
          "value": {
            "type": ["string", "null"],
            "description": "The specific brand name if mentioned, or null if no brand is mentioned",
            "enum": [
              "abrila", "activeallbrite", "agoky", "aidntbeo", "aidsci", "aiex", "aigostar", "alipis", "amijoux", "andreslad", "ariete", "atengeus", "ateroll", "aygrochy", "azorex", "bastilipo", "becken", "beper", "bestlivings", "bestron", "bestxh", "beyond breeze", "bibury", "bilake", "black+decker", "box plus", "bulltek", "cabilock", "casa shop", "cecotec", "childweet", "ciyodo", "clar", "clatronic", "clivex", "cmp", "cnanrnanc", "cnaohghn", "costway", "create", "crilstyleo", "cuayaes", "cunsieun", "diveblues", "djzz", "dlazum", "dovecina", "dr.prepare", "dreamhigh", "dreo", "dupi", "duronic", "duux", "dyson", "eayoly", "eden pulse", "edm", "electrotek", "epochglo", "escoll", "evvo", "extfans", "ezify", "f-air", "fabrilamp", "facula", "fm", "fuhai-666", "g3 ferrari", "garland", "garza", "generic", "genérico", "geteawily", "gliti", "gridinlux", "growmania.es", "grunkel", "gsc evolution", "gvdv", "gy", "habitex", "hanou", "haverland", "hg power", "hgbfmij", "hjjp", "hjm", "homcom", "huifengjie", "hzone", "iefiel", "iiniim", "infiniton electronics", "iris ohyama", "jarden", "jata", "jayruit", "jervamni", "jisulife", "jiuyekew", "jizzu", "jmh", "jmomc", "jocca", "johnson", "jophek", "jr bro", "kapaunn", "kesser", "koonie", "korona", "kouga zhang", "kucocosneh", "kumosaga", "kuxiptin", "lasko", "lbstp", "levoit", "lifkome", "lucci air", "m ledme", "magiclulu", "maurer", "max star", "maxellpower", "medion", "mellerware", "merca tools", "mercatools", "mill", "miss miserable", "mobutofu", "moluckfu", "movehii", "mpm", "mresiont", "msw motor technics", "mundofan", "muvip", "namvo", "neoferr", "newday", "newlux", "niceneeded", "norhes", "ocoopa", "omisoon", "orbegozo", "orework", "orion91", "osculati", "oxylops", "pearl", "pelonis", "philips", "philips lighting", "piqstore", "pretyzoom", "primevolve", "princess", "pro breeze", "pur line", "puremate", "qiachip", "raydan home", "reiga", "resaes resistant and aesthetic", "richday", "rowenta", "russell hobbs", "s&p", "sadrim", "senelux", "senmeo", "shavingfun", "shinic", "sin marca", "smjy", "sogo", "solace", "soler y palau", "spc", "stafu", "svan", "sweper", "swoomey", "taurus", "taylor swoden", "thinia home", "thomson", "thulos", "tiazhan", "tidyard", "tienda eurasia", "togeval", "topbathy", "towear", "treer", "tristar", "trotec", "tukrool", "u ultty", "uboon", "ufesa", "universalblue", "uzman", "vemont", "vevor", "vicasky", "viola", "voniry", "vonlimen", "wastou", "westinghouse", "wiltec", "withouse", "woda shang mao", "wonder pro wp", "wowdsgn", "yissvic", "ykgutilu", "yoevu", "ysjx", "zagon", "zeadio", "zerodis", "zfg", "zizinet",
              null
            ]
          }
        },
        "required": ["is_mentioned", "value"],
        "description": "Refers to the manufacturer or brand name of the fan. Brand can be an important factor for users looking for specific quality, features, or design associated with certain manufacturers."
      },
      "fan_type": {
        "type": "object",
        "properties": {
          "is_mentioned": {
            "type": "boolean",
            "description": "Indicates whether a specific fan type is mentioned in the search query"
          },
          "value": {
            "type": "string",
            "enum": [
              "Ceiling Fan",
              "Wall Fan",
              "Table Fan",
              "Stand Fan",
              "Tower Fan",
              "Floor Fan",
              "Portable Fan",
              "Industrial Fan",
              "Accesories for Fans",
              "Not specified"
            ],
            "description": "The specific type of fan if mentioned"
          }
        },
        "required": ["is_mentioned", "value"],
        "description": "Indicates the general category or style of the fan. This can include various designs suited for different purposes or mounting options, such as ceiling fans, portable fans, or industrial fans."
      },
      "decibels": {
        "type": "boolean",
        "description": "Relates to the noise level of the fan, indicating how loud or quiet it is during operation. This is important for users who are sensitive to noise or need a fan for quiet environments like bedrooms or offices."
      },
      "speeds": {
        "type": "boolean",
        "description": "Refers to the number of speed settings available on the fan. Multiple speeds allow users to adjust the airflow according to their needs, providing versatility in different weather conditions or personal preferences."
      },
      "connectivity": {
        "type": "boolean",
        "description": "Describes the fan\'s smart features or remote control options. This can include WiFi connectivity, app control, or compatibility with smart home systems, offering convenience and advanced functionality."
      },
      "timer": {
        "type": "boolean",
        "description": "Indicates whether the fan has a programmable timer function. This feature allows users to set the fan to turn off automatically after a certain period, which can be useful for energy saving or nighttime use."
      },
      "oscillating": {
        "type": "boolean",
        "description": "Refers to the fan\'s ability to rotate back and forth, distributing air over a wider area. This feature is particularly useful for cooling larger spaces or providing more even air circulation."
      },
      "adjustable_tilt": {
        "type": "boolean",
        "description": "Indicates whether the fan\'s head can be tilted or adjusted vertically. This feature allows users to direct airflow to specific areas, enhancing comfort and cooling efficiency."
      },
      "power": {
        "type": "boolean",
        "description": "Relates to the fan\'s energy consumption or motor power. This can be an indicator of the fan\'s strength and efficiency, which is important for users concerned about energy usage or those needing a particularly powerful fan."
      },
      "blade_material": {
        "type": "boolean",
        "description": "Specifies the material used for the fan blades. Different materials can affect the fan\'s durability, noise level, and aesthetic appeal, catering to various user preferences and needs."
      },
      "blade_color": {
        "type": "boolean",
        "description": "Indicates the color of the fan blades. This aesthetic feature can be important for users looking to match their fan with their room\'s decor or overall design theme."
      },
      "diameter": {
        "type": "object",
        "properties": {
          "is_mentioned": {
            "type": "boolean",
            "description": "Indicates whether fan diameter is mentioned in the search query"
          },
          "value": {
            "type": "number",
            "description": "The specific diameter in appropriate units if mentioned"
          }
        },
        "required": ["is_mentioned"],
        "description": "Refers to the size of the fan, typically measured by the diameter of the blade sweep. This dimension is crucial for understanding the fan\'s coverage area and its suitability for different room sizes or outdoor spaces."
      },
      "number_of_blades": {
        "type": "object",
        "properties": {
          "is_mentioned": {
            "type": "boolean",
            "description": "Indicates whether the number of blades is mentioned in the search query"
          },
          "value": {
            "type": "number",
            "description": "The specific number of blades if mentioned"
          }
        },
        "required": ["is_mentioned"],
        "description": "Specifies how many blades the fan has. The number of blades can affect the fan\'s performance, noise level, and appearance, with different configurations suited to different needs and preferences."
      },
      "retractable_blades": {
        "type": "boolean",
        "description": "Indicates whether the fan has blades that can be retracted or folded away when not in use. This feature can be beneficial for storage, cleaning, or in multi-functional spaces."
      },
      "integrated_lighting": {
        "type": "boolean",
        "description": "Refers to whether the fan includes built-in lighting fixtures. This dual-functionality can be particularly useful in rooms where both air circulation and overhead lighting are needed."
      },
      "color_temperature": {
        "type": "boolean",
        "description": "Relates to the color of the light emitted by integrated lighting fixtures. This feature allows users to adjust the ambiance of their space, from warm, cozy lighting to cool, energizing light."
      },
      "energy_efficiency": {
        "type": "boolean",
        "description": "Indicates the fan\'s energy efficiency rating. This is important for users looking to minimize energy consumption and potentially reduce electricity costs."
      },
      "summer_winter_function": {
        "type": "boolean",
        "description": "Indicates whether the fan has a reversible function that allows it to be used effectively in both summer and winter. In summer, it can create a cooling breeze, while in winter, it can help circulate warm air from heating systems, making it a versatile year-round appliance."
      }
    },
    "required": [
      "brand",
      "fan_type",
      "decibels",
      "speeds",
      "connectivity",
      "timer",
      "oscillating",
      "adjustable_tilt",
      "power",
      "blade_material",
      "blade_color",
      "diameter",
      "number_of_blades",
      "retractable_blades",
      "integrated_lighting",
      "color_temperature",
      "energy_efficiency",
      "summer_winter_function"
    ],
    "additionalProperties": false
  }
}'
FROM (
    SELECT DISTINCT
        CAST(JSON_EXTRACT(properties, '$.node_id') AS UNSIGNED) AS category_id
    FROM job_statuses
    WHERE id >= 9712
        AND type = 'best_seller'
        AND status != 'failed'
        AND JSON_EXTRACT(properties, '$.node_id') IS NOT NULL
) js
ON DUPLICATE KEY UPDATE
    KeywordCriteria = VALUES(KeywordCriteria);