
{
  "id": "vsetattr",
  "title": "VSETATTR",
  "url": "https://redis.io/docs/latest/commands/vsetattr/",
  "summary": "Associate or remove the JSON attributes of elements.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-05-27T13:11:51-07:00",
  "page_type": "content",
  "content_hash": "1a65b1b7997545c1d477bae2eb529dd0e3b84e41b967a87deabdc11c71ed5f34",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Associate a JSON object with an element in a vector set. Use this command to store attributes that can be used in filtered similarity searches with `VSIM`.\n\nYou can also update existing attributes or delete them by setting an empty string.\n\n[code example]\n\nTo remove attributes, pass an empty JSON string:\n\n[code example]"
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open>\n<summary><code>key</code></summary>\n\nis the name of the key that holds the vector set.\n</details>\n\n<details open>\n<summary><code>element</code></summary>\n\nis the name of the element whose attributes you want to set or remove.\n</details>\n\n<details open>\n<summary><code>json</code></summary>\n\nis a valid JSON string. Use an empty string (`\"\"`) to delete the attributes.\n</details>"
    },
    {
      "id": "related-topics",
      "title": "Related topics",
      "role": "related",
      "text": "- [Vector sets](https://redis.io/docs/latest/develop/data-types/vector-sets)"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Not supported\"><nobr>&#x274c; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Integer reply](../../develop/reference/protocol-spec#integers): 0 if either the key or element does not exist; 1 if the attributes were successfully added to the element.\n* [Simple error reply](../../develop/reference/protocol-spec/#simple-errors) for improperly specified attribute string.\n\n**RESP3:**\n\nOne of the following:\n* [Boolean reply](../../develop/reference/protocol-spec#booleans): false if either the key or element does not exist; true if the attributes were successfully added to the element.\n* [Simple error reply](../../develop/reference/protocol-spec/#simple-errors) for improperly specified attribute string."
    }
  ],
  "examples": [
    {
      "id": "overview-ex0",
      "language": "shell",
      "code": "VSETATTR key element \"{\\\"type\\\": \\\"fruit\\\", \\\"color\\\": \\\"red\\\"}\"",
      "section_id": "overview"
    },
    {
      "id": "overview-ex1",
      "language": "shell",
      "code": "VSETATTR key element \"\"",
      "section_id": "overview"
    }
  ]
}
