When to use this
You needSearchType.TRIPLET_COMPLETION to return results. This search type matches queries against text representations of graph triplets (source → relationship → target). The create_triplet_embeddings pipeline creates these embeddings.
Before you start:
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Have an existing knowledge graph (add → cognify completed)
Code in Action
What Just Happened
- Add + Cognify — builds a knowledge graph with entities and relationships from your text.
get_default_user()— retrieves the authenticated user. This pipeline requires aUserobject with write access to the dataset.create_triplet_embeddings(user, dataset)— iterates over all graph triplets, converts each to a text representation, and indexes them in the vector DB.- Search with
TRIPLET_COMPLETION— queries the newTriplet_textcollection by semantic similarity.
What Changed in Your Graph
- The
Triplet_textcollection is populated in the vector DB. Each entry is a text representation of a graph triplet (source → relationship → target). SearchType.TRIPLET_COMPLETIONqueries now return results by matching your query against these triplet embeddings.
Parameters
Parameters
user(User, required) — authenticated user with write access. Obtain viaawait get_default_user().dataset(str, default:"main_dataset") — the dataset whose graph triplets to index.run_in_background(bool, default:False) — run asynchronously and return immediately.triplets_batch_size(int, default:100) — how many triplets to index per batch. Lower values use less memory; higher values are faster.
Under the hood
Under the hood
Two tasks run in sequence:
get_triplet_datapoints— iterates over graph triplets and yieldsTripletobjects with embeddable text.index_data_points— indexes each triplet in the vector DB under theTriplet_textcollection.
Troubleshooting
Troubleshooting
- Empty results from
TRIPLET_COMPLETION— ensure the graph has been built (cognify completed) and thatcreate_triplet_embeddingsfinished without errors. - Error: no graph data found — run
cognee.add()andcognee.cognify()before calling this pipeline. - LLM errors — verify that your LLM provider is configured. See LLM Providers.
- Permission errors — the user must have write access to the target dataset. See Permissions.