Tanuj Gupta
01/21/2025, 4:29 PM{
"customer": {
"name": "Customer Name"
},
"destination": {
"appointment": {
"start": {
"date": "2024-01-01",
"time": "12:00",
"timezone": "America/New_York"
}
},
"arrivalDateTime": {
"date": "2024-01-02",
"time": "14:00",
"timezone": "America/New_York"
},
"departureDateTime": {
"date": "2024-01-01",
"time": "15:00",
"timezone": "America/New_York"
},
"warehouse": {
"address": {
"city": "Destination City",
"stateCode": "ST"
}
}
},
"origin": {
"appointment": {
"start": {
"date": "2024-01-01",
"time": "08:00",
"timezone": "America/New_York"
}
},
"arrivalDateTime": {
"date": "2024-01-01",
"time": "10:00",
"timezone": "America/New_York"
},
"departureDateTime": {
"date": "2024-01-01",
"time": "11:00",
"timezone": "America/New_York"
},
"warehouse": {
"address": {
"city": "Origin City",
"stateCode": "ST"
}
}
},
"drivers": [
{
"phoneNumber": "1234567890"
}
],
"dispatchers": [
{
"email": "<mailto:dispatcher@example.com|dispatcher@example.com>"
}
]
}
Fields I now need to index include:
• destination.appointment.start.date
• destination.arrivalDateTime.date
• destination.departureDateTime.date
• destination.warehouse.address.city
• destination.warehouse.address.stateCode
• origin.appointment.start.date
• origin.arrivalDateTime.date
• origin.departureDateTime.date
• origin.warehouse.address.city
• origin.warehouse.address.stateCode
• customer.name
• drivers.phoneNumber
• dispatchers.email
My Questions:
1. Flattening vs. Nested Indexing: Should I extract all these fields to top-level keys for indexing, or is it better to keep them nested?
◦ Are there performance implications or best practices to consider?
2. Search Optimization: Would indexing these deeply nested fields directly impact search performance compared to flat fields?
3. Future Scalability: If more nested fields need to be indexed later, how should I design my schema to accommodate these changes efficiently?
Any advice or suggestions for structuring my data and schema to handle these requirements effectively would be greatly appreciated. Thank you!Fanis Tharropoulos
01/23/2025, 9:48 AMdestination.warehouse.address.city
). During searching, there's a minor overhead from deleting these flattened fields before returning results, but it shouldn't even be noticeableTanuj Gupta
01/23/2025, 5:06 PM