
Alaa Al-Hamadaniπ Building Hybrid Search for Koli One Using Algolia + Firestore (2026 Architecture Deep-Dive) How we...
π Building Hybrid Search for Koli One Using Algolia + Firestore (2026 Architecture Deep-Dive)
How we combined Firestoreβs consistency with Algoliaβs instant search to power Bulgariaβs next-generation automotive marketplace.
π Introduction
At Koli One, we faced a clear challenge: how to build a search system that was fast, intelligent, and flexible enough to handle the needs of the Bulgarian automotive market?
Searching for cars isn't just about βtextββit requires:
Precise matching (VIN, license plate number, ID)
Fuzzy search (BMW β BMV β BWM)
Multiple filters (price, year, fuel type, city)
Geographic search (cars within 10 km of Sofia)
Natural queries (blue BMW under 15,000 in Sofia)
Neither Firestore nor Algolia alone was enough.
The solution? Hybrid Search Architecture.
π§© Cover Image (Architecture Diagram)
(Use the system image we created previously β the diagram showing Firestore + Algolia + Query Router)
π Why did we choose Hybrid Search?
Firestore excels at:
Strong consistency
Precise queries
Geoqueries
Real-time updates
But Firestore is weak in:
Full-text search
Fuzzy matching
Fasted filters
Ranking
Algolia excels at:
Instant search
Type tolerance
Fasting
Ranking
NLP-friendly search
But Algolia is not a database.
So we built a system that combines both.
ποΈ Architecture Overview
The Koli One search system works as follows:
Writing Code
User
β
Query Parser (NLP)
β
Query Router
ββββββββββββββββ
Firestore Algolia
β β
Merge + Dedupe
β
UI
Firestore = Source of Truth
All cars, seller data, conditions, and geolocation are stored in the Firestore.
Algolia = Search Accelerator
We send an enhanced version of the car data to Algolia via Cloud Functions.
Query Router
Simple Query β Firestore
Text Query β Algolia
Geographic Query β Firestore
Combined Query β Algolia + Firestore
βοΈ Algolia Integration
Index Schema
json
{
"objectID": "car123",
"title": "2018 BMW X5",
"make": "BMW",
"model": "X5",
"year": 2018,
"price": 45000,
"city": "Sofia",
"_geoloc": {"lat": 42.6977, "lng": 23.3219},
"searchableAttributes": ["title", "make", "model"]
}
Faceting Configuration
We have enabled the following filters:
make
model
city
fuelType
condition
vehicleType
Replica Indices
For sorting results:
cars_bg (default relevance)
cars_bg_price_asc
cars_bg_price_desc
cars_bg_createdAt_desc
Cost Optimization
Only upload cars to Algolia:
Published cars only (status: active)
Not drafts or deleted cars
π₯ Firestore Query Layer
Firestore is used for:
Exact match queries
Geo queries
Seller inventory
Numeric ID retrieval
Example:
js
cars.where("make", "==", "BMW")
.where("city", "==", "Sofia")
π§ Query Router Logic
Decision Tree
brand + city β Firestore
βblue BMW in Sofiaβ β Algolia + NLP
geo + radius β Firestore
fuzzy text β Algolia
Example Code
js
function routeQuery(query) {
if (isExact(query)) return searchFirestoreExact(query);
if (isGeoQuery(query)) return searchFirestoreGeo(query);
if (isNaturalLanguage(query)) {
const parsed = parseNLP(query);
return searchAlgolia(parsed);
}
return searchAlgolia(query);
}
π Results
Average search time: < 60ms
Higher accuracy in results
Natural query support
A modern search experience similar to Google
π Conclusion
Hybrid Search using Algolia + Firestore gave us:
Speed
Intelligence
Flexibility
Scalability
Excellent user experience
This system is the backbone of Koli One's auto-search.
π Tags
architecture #firebase #algolia #typescript #webdev