Overview
The Finvest Finance Advisor demonstrates Cloud Spanner’s multi-modal capabilities for complex financial services workloads. This application showcases how to combine relational data, full-text search, semantic vector search, and graph traversal in a single platform.
Use Case: Investment Fund Discovery
A financial advisor needs to find suitable funds for a client with complex requirements:- Geographic focus: North America and Europe
- Asset type: Funds investing in derivatives
- Fund manager: Name contains “Liz Peters” (fuzzy match)
- ESG criteria: Socially responsible investments
- Sector exposure: Technology sector ≥ 20% (including fund-of-funds)
Architecture
Full-Text Search
SEARCH() and SEARCH_NGRAMS() for fuzzy name matching
Vector Search
ANN with APPROX_EUCLIDEAN_DISTANCE for semantic similarity
Graph Queries
GRAPH pattern matching for fund-of-funds sector exposure
Multi-Modal Search Capabilities
1. Full-Text Search with Token Matching
Use case: Find funds investing in derivatives across regionsinvestment_strategy_Tokensis a token search index on the strategy textSEARCH()performs full-text matching on tokenized content- Returns exact matches for “derivatives” in investment strategy descriptions
2. Fuzzy Substring Matching with N-Grams
Use case: Find fund manager “Elizabeth Peterson” when searching “Liz Peters”SEARCH_NGRAMS()finds substring matches using n-gram indexesSCORE_NGRAMS()ranks results by similarity scoremin_ngrams=>1allows flexible matching (“Liz” matches “Elizabeth”)- Combines with full-text search for multi-criteria filtering
3. Semantic Vector Search with Embeddings
Use case: Find “socially responsible” funds (matches ESG without exact keyword)- K-NN: Exact search, slower, guarantees optimal results
- ANN: Approximate search, faster, trades accuracy for speed
- Use ANN when: Dataset size > 10K vectors, latency < 100ms required
4. Hybrid Search: Vector + Full-Text + Fuzzy
Use case: All criteria combined5. Graph Queries for Fund-of-Funds
Use case: Calculate sector exposure including nested fund holdingsGRAPH FundGraphreferences the graph schema defined in SpannerMATCHpattern traverses fund → company → sector relationships- Handles fund-of-funds: funds can hold other funds, which hold companies
SUM(h.percentage)aggregates holdings across all pathsNEXTclause filters aggregated results (SQL WHERE equivalent)
Spanner ML Integration
Configure Vertex AI Model
Generate Embeddings During Data Load
Create Vector Search Index
Python Application Architecture
Database Connection
Search Functions
Streamlit Interface
Deployment
Import Database
Use Spanner’s import feature with the public export:Source bucket:This creates the database with schema and sample data.
Run Remaining DDL
Execute the rest of
Schema-Operations.sql to create:- Full-text search indexes
- Vector embeddings columns
- ANN search index
- Graph schema definition
Performance Characteristics
Latency Benchmarks
| Query Type | Latency (p50) | Latency (p99) |
|---|---|---|
| Full-text search | 15ms | 50ms |
| K-NN (10K vectors) | 45ms | 120ms |
| ANN (1M vectors) | 18ms | 60ms |
| Graph traversal (3 hops) | 25ms | 80ms |
| Hybrid (ANN + full-text) | 35ms | 95ms |
Scalability
- Storage: Unlimited (tested with 10TB+)
- Throughput: 10,000+ QPS per node
- Concurrency: 10,000+ concurrent queries
- Availability: 99.999% (5 nines)
- Replication: Multi-region with strong consistency
Troubleshooting
ML.PREDICT returns permission denied
ML.PREDICT returns permission denied
Grant Spanner service account Vertex AI User role:
Vector search returns no results
Vector search returns no results
Ensure:
- Embeddings column populated:
SELECT COUNT(*) FROM EU_MutualFunds WHERE investment_strategy_Embedding IS NOT NULL - Vector index created and online
- Query uses parameterized vector input (
@vector)
Graph query fails
Graph query fails
Verify graph schema:Check edge table foreign keys are valid.
Key Takeaways
Single Platform
Spanner eliminates need for multiple specialized databases
Strong Consistency
Multi-modal queries with ACID guarantees
Unlimited Scale
Horizontal scaling without sharding complexity
Low Latency
ANN search + graph traversal in sub-100ms
Next Steps
- Try GenWealth’s AlloyDB implementation
- Compare with FixMyCar’s Vertex AI Search
- Build voice AI with Gemini Live