Visitar URL original
docs: Add MongoDB data-source and offline-store reference documentation by jvincent-mongodb · Pull Request #6351 · feast-dev/feast · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: various copy revisions
Signed-off-by: jvincent-mongodb <jeffrey.vincent@mongodb.com>
  • Loading branch information
jvincent-mongodb committed Apr 30, 2026
commit 506d235fa44b4cc5a151ee89b8b5ebe20bd91701
8 changes: 5 additions & 3 deletions docs/reference/offline-stores/mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
## Description

The MongoDB offline store provides support for reading [MongoDBSource](../data-sources/mongodb.md).
* Entity dataframes can be provided as a Pandas dataframe. The offline store converts entity identifiers into serialized entity keys for efficient lookup against the `feature_history` collection.
* Uses a single shared `feature_history` collection with a compound index for all FeatureViews, distinguished by a `feature_view` discriminator field.
* Entity dataframes can be provided as a Pandas dataframe. The offline store converts entity identifiers into serialized entity keys for efficient lookup against the `feature_history` collection.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip the description.

## Getting started

Expand All @@ -26,6 +26,8 @@ online_store:
type: mongodb
connection_string: "mongodb+srv://user:pass@cluster.mongodb.net"
Comment thread
jvincent-mongodb marked this conversation as resolved.
Outdated
database_name: feast_online_store
collection_suffix: latest
client_kwargs: {}
```
{% endcode %}

Expand Down Expand Up @@ -66,8 +68,8 @@ This index enables efficient range scans over entities and feature views, while
## Key Optimizations

* **K-collapse**: Multiple FeatureViews that share the same join keys are queried in a single aggregation using `feature_view: {$in: [...]}`, reducing round trips.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual get_historical_features implementation loops over each proj_name in fv_to_features and issues separate MongoDB aggregation pipelines per feature view.

K-collapse can be enhancements?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. K-collapse was removed after the complication around projection keys was discovered. Two projections, same feature view. Thank you for pointing this out. I may have to change docstrings too.

* **Scoring vs. training paths**: When `entity_df` has unique entity IDs (scoring), server-side `$group $first` is used for efficient retrieval. When entity IDs repeat (training), `pd.merge_asof` provides correct point-in-time joins.
* **Two-level chunking**: Outer `CHUNK_SIZE` (50,000 rows) limits the entity DataFrame slice; inner `MONGO_BATCH_SIZE` (10,000 entity IDs) limits `$in` array size per aggregation call.
* **Scoring vs. training paths**: When each entity appears only once in `entity_df` (scoring/inference — one feature lookup per entity), server-side `$group $first` efficiently returns the single latest value per entity. When the same entity appears at multiple timestamps (training — building a dataset with many historical snapshots per entity), the store retrieves all candidate rows and uses `pd.merge_asof` to select the correct point-in-time value for each request timestamp.
* **Two-level chunking**: `CHUNK_SIZE` (50,000 rows) controls the size of intermediate DataFrames in memory; `MONGO_BATCH_SIZE` (10,000 entity IDs) limits the query size sent to MongoDB.

## Functionality Matrix

Expand Down