{"record":{"id":"994555a6ce8c52fd","repo":"cocoindex-io/cocoindex","slug":"build-relationship-index-create-requires-at-least","errorCode":null,"errorMessage":"build_relationship_index_create requires at least one field","messagePattern":"build_relationship_index_create requires at least one field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/falkordb/_cypher.py","lineNumber":161,"sourceCode":"    \"\"\"``CREATE INDEX FOR (e:`Label`) ON (e.`f1`, e.`f2`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_node_index_create requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"CREATE INDEX FOR (e:{_quote(label)}) ON ({field_list})\"\n\n\ndef build_node_index_drop(label: str, fields: Sequence[str]) -> str:\n    \"\"\"``DROP INDEX FOR (e:`Label`) ON (e.`f1`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_node_index_drop requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"DROP INDEX FOR (e:{_quote(label)}) ON ({field_list})\"\n\n\ndef build_relationship_index_create(rel_type: str, fields: Sequence[str]) -> str:\n    \"\"\"``CREATE INDEX FOR ()-[e:`RelType`]-() ON (e.`f1`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_relationship_index_create requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"CREATE INDEX FOR ()-[e:{_quote(rel_type)}]-() ON ({field_list})\"\n\n\ndef build_relationship_index_drop(rel_type: str, fields: Sequence[str]) -> str:\n    \"\"\"``DROP INDEX FOR ()-[e:`RelType`]-() ON (e.`f1`, ...)``.\"\"\"\n    if not fields:\n        raise ValueError(\"build_relationship_index_drop requires at least one field\")\n    field_list = \", \".join(f\"e.{_quote(f)}\" for f in fields)\n    return f\"DROP INDEX FOR ()-[e:{_quote(rel_type)}]-() ON ({field_list})\"\n\n\ndef build_vector_index_create(\n    label: str,\n    field: str,\n    dimension: int,\n    metric: str,\n) -> str:","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/falkordb/_cypher.py#L143-L179","documentation":"Input guard in the FalkorDB Cypher builder: a relationship index needs at least one property, so an empty fields sequence would render invalid Cypher (CREATE INDEX ... ON ()). Raised before the query is sent so the failure is attributable to the caller's schema rather than the database. Occurs when the relationship type's declared index fields list is empty; supply at least one field.","triggerScenarios":"Calling build_relationship_index_create(rel_type, fields=[]) — a relationship index spec with a type but no properties.","commonSituations":"Relationship index config defaulted to empty; field names filtered out because they didn't match relationship properties; user assumed relationship indexes need no fields.","solutions":["Pass at least one relationship property to index.","Skip the index declaration if no property needs indexing.","Check upstream config parsing to see why the fields list is empty."],"exampleFix":"// before\nbuild_relationship_index_create(rel_type=\"WORKS_AT\", fields=[])\n// after\nbuild_relationship_index_create(rel_type=\"WORKS_AT\", fields=[\"since\"])","handlingStrategy":"validation","validationCode":"if not fields:\n    raise ValueError('relationship index requires at least one field')\ncypher = build_relationship_index_create(rel_type, fields)","typeGuard":"def indexable(fields: object) -> bool:\n    return isinstance(fields, (list, tuple)) and len(fields) > 0 and all(isinstance(f, str) for f in fields)","tryCatchPattern":"try:\n    cypher = build_relationship_index_create(rel_type, fields)\nexcept ValueError as e:\n    logger.warning('skipping relationship index on %s: %s', rel_type, e)\n    cypher = None","preventionTips":["Declare relationship indexes only when at least one relationship property needs indexing.","Validate the index spec (type + fields) when the schema is loaded.","Ensure field names match actual relationship properties so filters don't drop them all."],"tags":["cypher","falkordb","index","relationship"],"backgroundTag":"missing-required-argument","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}