Retrieving nested cross-references during querying
In our database, we have three data classes: Chunk, Document, and Corpus.
Corpora contain Documents, which is stored by the documents having a corpus property that cross-references the Corpus object they belong to.
Likewise, Documents contain Chunks, which is again stored by chunks having a document property that cross-references the Document object they belong to.
Cross-reference scheme: Chunk --> Document --> Corpus
When querying chunks, I would like to retrieve fields for the chunks themselves as well as fields of the cross-referenced document and the corpus that this document cross-references, that is, from a chunk object I would like to follow the path:
["document", "Document", "corpus", "Corpus", "source"], where source is a property of class Corpus.
This works fine when filtering using exactly this value given here for path.
# Get all chunks for the corpus
where_clause = {
"path": ["document", "Document", "corpus", "Corpus, "id"],
"operator": "Equal", "valueText": corpus_id
}
However, I am only able to get properties of the cross-referenced Document object but not of the further cross-referenced Corpus object when querying chunks like this:
result = self.client.query \
.get(class_name="Chunk",
properties=[
"text",
"document {... on Document {url}}",
"document {... on Document { corpus {... on Corpus {source}}}}"
]) \
.with_near_vector({"vector": query_vector}) \
.do()
The result always contains the url property from the cross-referenced Document object, but not the source property from the nested cross-referenced Corpus object. Instead, I get a corpus property with a null value back:
'document': ['corpus': None, 'url': 'https://myurl.com/'}].
Since filtering seems to work fine with these multi-level cross-references, I figure it should also work with querying. However, I have found no way to get it to work. The syntax validation of the property string basically tells me that document {... on Document { corpus {... on Corpus {source}}}} is well-formed (and everything else I tried is not). I am not excluding that I am just using the wrong syntax or approach but I also did not find any hints in the Weaviate documentation.
Thank you very much for considering my issue and thanks for an excellent vector database!
Thank you for your contribution to Weaviate. This issue has not received any activity in a while and has therefore been marked as stale. Stale issues will eventually be autoclosed. This does not mean that we are ruling out to work on this issue, but it most likely has not been prioritized high enough in the last months. If you believe that this issue should remain open, please leave a short reply. This lets us know that the issue is not abandoned and acts as a reminder for our team to consider prioritizing this again. Please also consider if you can make a contribution to help with the solution of this issue. If you are willing to contribute, but don't know where to start, please leave a quick message and we'll try to help you. Thank you, The Weaviate Team