Find answers from the community

Updated 6 months ago

How do I see how many documents I have added to a Property Graph Index?

At a glance

The post asks how to see the number of documents added to a Property Graph Index. Community members provided the following answers:

If using MongoDB as the vector store, the count_documents method can be used. If using BagelIndex, the count method can be used.

For Neo4j, the community members suggested using a Cypher statement to get the number of nodes, and then a different Cypher statement to get the number of distinct documents (since documents are split into nodes).

How do I see how many documents I have added to a Property Graph Index?
k
C
L
9 comments
Please stand by @Callam as I search the knowledge base. I normally take about 20 seconds or so. :wave:
----------------------
To see how many documents you have added to a Property Graph Index, you can use the count_documents method if you are using MongoDB as your vector store, or the count method if you are using BagelIndex. Here are examples of how to use these methods:

If you are using MongoDB:
Plain Text
print(store._collection.count_documents({}))

Source ()

If you are using BagelIndex:
Plain Text
print("Count of documents:", cluster.count())

Source ()

Please replace store and cluster with your actual instances.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
@kapa.ai I am using Neo4j? how do I do it?
hmm, there should be a cypher statement for this
I can get you nodes

number_of_nodes = index.property_graph_store.structured_query("match (n:Chunk) return count(n)")
Ah, here's the cypher for number of documents (remember, documents get split into nodes)

match (n:Chunk) with n.ref_doc_id as id return count(distinct id)
This is honestly my favorite part about this index -- having access to cypher is very helpful (the syntax is a little weird, but chatgpt helps)
Thank you Logan !
always coming in clutch
Add a reply
Sign up and join the conversation on Discord