Basic Usage
This guide covers saving documents to your Endee vector store and querying them for similarity search.
Saving Documents
Store documents with metadata in your Endee vector store:
documents = [
("Python is dynamically typed.", {"creator": "Guido van Rossum", "typing": "dynamic"}),
("Go is statically typed.", {"creator": "Robert Griesemer", "typing": "static"})
]
for text, meta in documents:
memory_store.save(text, meta)
print(f"Saved {len(documents)} documents")Each document consists of:
- Text content — The actual text to be embedded and stored
- Metadata — Key-value pairs for filtering and organization
Querying the Vector Store
Perform semantic search to find relevant documents:
results = memory_store.search(
query="Python typing discipline",
limit=3,
filter={"typing": {"$eq": "dynamic"}}
)
for r in results:
print(f"ID: {r['id']}, Score: {r['score']}, Text: {r['context']}")Query Parameters
| Parameter | Type | Description |
|---|---|---|
query | str | The search query text |
limit | int | Maximum number of results to return |
filter | dict | Optional metadata filter conditions |
Filter Operators
| Operator | Description | Example |
|---|---|---|
$eq | Equal to | {"typing": {"$eq": "dynamic"}} |
$in | In list | {"tags": {"$in": ["ai", "ml"]}} |
$range | Numeric range | {"score": {"$range": [70, 95]}} |
Query Results
Each result in the response contains:
| Field | Description |
|---|---|
id | Unique identifier for the document |
score | Similarity score (higher is more relevant) |
context | The original text content |
metadata | Associated metadata |
Complete Example
from endee_crewai import EndeeVectorStore
import time
# Initialize
embedder_config = {
"provider": "cohere",
"config": {"model_name": "small", "api_key": "<COHERE_API_KEY>"}
}
memory_store = EndeeVectorStore(
type="programming_languages",
api_token="<ENDEE_API_TOKEN>",
embedder_config=embedder_config,
space_type="cosine",
crew=None,
)
# Save documents
documents = [
("Python is dynamically typed and great for beginners.", {"language": "python", "typing": "dynamic"}),
("Go is statically typed with built-in concurrency.", {"language": "go", "typing": "static"}),
("JavaScript runs in browsers and Node.js.", {"language": "javascript", "typing": "dynamic"}),
("Rust provides memory safety without garbage collection.", {"language": "rust", "typing": "static"})
]
for text, meta in documents:
memory_store.save(text, meta)
time.sleep(1) # Allow indexing
# Query for dynamic languages
results = memory_store.search(
query="beginner friendly programming",
limit=2,
filter={"typing": {"$eq": "dynamic"}}
)
print("Dynamic languages for beginners:")
for r in results:
print(f" - {r['context']} (score: {r['score']:.4f})")