{"record":{"id":"835fa9b9ba1684e6","repo":"run-llama/llama_index","slug":"simplegraphstore-does-not-support-query","errorCode":null,"errorMessage":"SimpleGraphStore does not support query","messagePattern":"SimpleGraphStore does not support query","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/graph_stores/simple.py","lineNumber":159,"sourceCode":"        persist_path: str = os.path.join(DEFAULT_PERSIST_DIR, DEFAULT_PERSIST_FNAME),\n        fs: Optional[fsspec.AbstractFileSystem] = None,\n    ) -> None:\n        \"\"\"Persist the SimpleGraphStore to a directory.\"\"\"\n        fs = fs or self._fs\n        dirpath = os.path.dirname(persist_path)\n        if not fs.exists(dirpath):\n            fs.makedirs(dirpath)\n\n        with fs.open(persist_path, \"w\", encoding=\"utf-8\") as f:\n            json.dump(self._data.to_dict(), f)\n\n    def get_schema(self, refresh: bool = False) -> str:\n        \"\"\"Get the schema of the Simple Graph store.\"\"\"\n        raise NotImplementedError(\"SimpleGraphStore does not support get_schema\")\n\n    def query(self, query: str, param_map: Optional[Dict[str, Any]] = {}) -> Any:\n        \"\"\"Query the Simple Graph store.\"\"\"\n        raise NotImplementedError(\"SimpleGraphStore does not support query\")\n\n    @classmethod\n    def from_persist_path(\n        cls, persist_path: str, fs: Optional[fsspec.AbstractFileSystem] = None\n    ) -> \"SimpleGraphStore\":\n        \"\"\"Create a SimpleGraphStore from a persist directory.\"\"\"\n        fs = fs or fsspec.filesystem(\"file\")\n        if not fs.exists(persist_path):\n            logger.warning(\n                f\"No existing {__name__} found at {persist_path}. \"\n                \"Initializing a new graph_store from scratch. \"\n            )\n            return cls()\n\n        logger.debug(f\"Loading {__name__} from {persist_path}.\")\n        with fs.open(persist_path, \"rb\") as f:\n            data_dict = json.load(f)\n            data = SimpleGraphStoreData.from_dict(data_dict)","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/graph_stores/simple.py#L141-L177","documentation":"SimpleGraphStore.query() unconditionally raises NotImplementedError (and note its param_map default is a mutable `{}`). SimpleGraphStore stores raw triples in dicts and exposes only direct get/upsert accessors — it has no query language interpreter, so any query-string API call is rejected rather than silently returning wrong results.","triggerScenarios":"Calling graph_store.query('MATCH (n) RETURN n') or any Cypher/SPARQL-style string on a SimpleGraphStore; generic query layers or LLM tool-calls that route a query string to whatever graph store is configured.","commonSituations":"Developing against Neo4j locally and deploying with the default simple store (or vice versa); KnowledgeGraphIndex flows that attempt structured queries; agent code that always calls query() regardless of backend.","solutions":["Switch to a query-capable backend (Neo4j, Neptune, Kuzu, etc.) via the corresponding llama-index integration.","For SimpleGraphStore, retrieve data with get_triplets()/get(subject, predicate) instead of a query string.","Wrap store access in an adapter that checks capability before issuing structured queries."],"exampleFix":"# before\nrows = graph_store.query(\"MATCH (s)-[p]->(o) RETURN s, p, o\")\n\n# after\ntriplets = graph_store.get_triplets()  # SimpleGraphStore supported API","handlingStrategy":"fallback","validationCode":"from llama_index.core.graph_stores.simple import SimpleGraphStore\n\nif isinstance(graph_store, SimpleGraphStore):\n    triplets = graph_store.get_triplets()  # supported access path\nelse:\n    rows = graph_store.query(cypher, param_map={})","typeGuard":"def supports_query(store) -> bool:\n    return not isinstance(store, SimpleGraphStore)","tryCatchPattern":"try:\n    rows = graph_store.query(query_str, param_map=params)\nexcept NotImplementedError:\n    rows = graph_store.get_triplets()  # degrade to direct triple access","preventionTips":["Never route query-language strings to SimpleGraphStore; use get/get_triplets.","Abstract retrieval behind a store adapter that knows each backend's capabilities.","Run integration tests per backend so unsupported paths fail in CI, not production."],"tags":["not-implemented","graph-store","unsupported-operation","query-language"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}