Replies: 1 comment 1 reply
-
🤖 Hey @gartija, I'm Dosu, a friendly bot that assists with bug fixing, answering questions, and guiding you through the contribution process on this repo. While we're waiting for a human maintainer to assist you, I'm here to help. Let's get your issue sorted! The error you're encountering, "redis.exceptions.ResponseError: Attribute 'id' is already indexed", is due to the fact that the code is attempting to create an index on the 'id' attribute of the nodes in the graph, which is already indexed. This happens in the self._driver.query(f"CREATE INDEX FOR (n:`{self._node_label}`) ON (n.id)") To resolve this issue, you can check if the index already exists before trying to create it. Unfortunately, RedisGraph (which FalkorDB is based on) does not currently support checking if an index exists directly. However, you can handle this by catching the Here's how you can modify the def __init__(
self,
url: str,
database: str = "falkor",
node_label: str = "Entity",
**kwargs: Any,
) -> None:
try:
import redis
except ImportError:
raise ImportError("Please install redis client: pip install redis")
"""Initialize params."""
self._node_label = node_label
self._driver = redis.Redis.from_url(url).graph(database)
try:
self._driver.query(f"CREATE INDEX FOR (n:`{self._node_label}`) ON (n.id)")
except redis.exceptions.ResponseError as e:
if "already indexed" not in str(e):
raise
self._database = database
self.schema = ""
self.get_query = f"""
MATCH (n1:`{self._node_label}`)-[r]->(n2:`{self._node_label}`)
WHERE n1.id = $subj RETURN type(r), n2.id
""" In this modified code, if the You can find more details about the I hope this helps! If you have any other questions, feel free to ask. Best, SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I wonder if someone has bumped into this issue. I created a KnowledgeGraphIndex from documents and stored it in a local FalkorDB as shown in the documentation. However, when I try to restore the index from Falkor instantiating the FalkorDBGraphStore I get the following error: "redis.exceptions.ResponseError: Attribute 'id' is already indexed".
If I look into the FalkorDBGraphStore init method the error makes sense since it's trying to create an index that already exists (because I already created the database), is this an error in the implementation or how can I instantiate a Falkor Graph store to retrieve the index from the store?
This is the code sample, the error is thrown on line 1, I cannot pass the instantiation part:
`graph_store = FalkorDBGraphStore(
"redis://localhost:6379", decode_responses=True,database="falkor2"
)
service_context = ServiceContext.from_defaults(llm=llmllama,embed_model='local', chunk_size=512)
storage_context = StorageContext.from_defaults(graph_store=graph_store)
index = load_index_from_storage(storage_context)`
Thanks for any help on this issue!
Beta Was this translation helpful? Give feedback.
All reactions