Thực hiện các bước sau:
• Tạo index đơn trường trên field price (tăng dần)
• Sau khi tạo index, truy vấn các listing có price > 300, sắp xếp theo price tăng dần; cùng giá thì theo _id tăng dần; lấy 10 listing đầu tiên
• Chỉ in ra: name, price (không hiển thị _id)
Chương trình in đúng hai thứ: tên index vừa tạo và kết quả câu truy vấn find (không cần lệnh use).
Collection listingsAndReviews (dữ liệu mẫu sample_airbnb.listingsAndReviews) đã được nạp sẵn.
Dòng đầu là tên index, tiếp theo là mảng 10 document theo định dạng mongosh (price kiểu Decimal128), ví dụ:
price_1
[
{
name: 'Studio Paisible - Petite Italie',
price: Decimal128('301.00')
},
...
]
Ví dụ:
Đầu vào:
sample_airbnb.listingsAndReviews
Đầu ra:
price_1
[
{
name: 'Studio Paisible - Petite Italie',
price: Decimal128('301.00')
},
{
name: 'Sunny loft-style apartment in Place-des-Arts !',
price: Decimal128('301.00')
},
{
name: 'DOWNTOWN VIP MONTREAL ,HIGH END DECOR,GOOD VALUE..',
price: Decimal128('301.00')
},
{
name: 'Suadiye bağdat caddesine 4. Bina',
price: Decimal128('301.00')
},
{
name: 'Victorian Apartment w/ Private Terrace',
price: Decimal128('301.00')
},
{
name: 'Very Safe, Peaceful, Reliable Istanbul can show.',
price: Decimal128('301.00')
},
{
name: 'Architectural Design Townhouse with Spa-worthy Tub',
price: Decimal128('301.00')
},
{ name: 'Modern house in Le Plateau', price: Decimal128('301.00') },
{
name: 'Stylish home at the best place of Istanbul',
price: Decimal128('301.00')
},
{
name: 'Lovely Queen Boutique Hotel Room',
price: Decimal128('301.00')
}
]Đang tải editor...