Sample JSON Collection
A travel-booking JSON collection is the common illustrative model reused throughout the indexing examples in this chapter.
create JSON collection table bookings;
insert into bookings values ('
{
"_id": "507f192e811c19709de860ef",
"traveler": {
"first": "Jane",
"last": "Doe",
"status": "silver",
"loyaltyPoints": 120,
"email": "jane.doe@example.com",
"phone": "+1-555-123-4567"
},
"reservations": [
{
"type": "flight",
"flightNumber": "DL456",
"departureCity": "London",
"arrivalCity": "New York",
"departureTime": "2024-05-05T08:00:00",
"arrivalTime": "2024-05-06T12:00:00",
"airline": "Comet Airlines",
"seat": "22A",
"confirmationNumber": "FGU89A"
},
{
"type": "flight",
"flightNumber": "DL457",
"departureCity": "New York",
"arrivalCity": "London",
"departureTime": "2024-05-03T22:00:00",
"arrivalTime": "2024-05-04T10:00:00",
"airline": "Comet Airlines",
"seat": "14C",
"confirmationNumber": "FGU89A"
},
{
"type": "hotel",
"hotelName": "London Palace",
"location": "London",
"checkIn": "2024-05-04",
"checkOut": "2024-05-07",
"roomType": "Standard Room",
"confirmationNumber": "LON67890"
}
],
"notes": "Traveler prefers window seats on a flight and requests accommodations that tend to be quieter with fewer street-side facing windows. Special dietary requirement is for vegetarian meals. Likes points program."
}
');
This data models a traveler record. The itinerary can contain multiple items, including flights, hotels, and cars. Some fields are queried by equality, while others are suited for full-text search.