Hello! First of all, thanks for the great product ...
# community-help
l
Hello! First of all, thanks for the great product you built. I have one question, if I have a property that is an array of timestamps in my collection (in domain words, is an array of dates in which a house is not available), how can i search only those documents in which that array does not contain any of the dates between a range (from, to) (in domain words, that would be the houses that are available between a checkin and checkout) For example, if my house has blocked 2023-06-14 and I search for houses that are available between 2023-06-13 and 2023-06-15, i should not see that house.
j
You would have to restructure your data a bit to do this from within in Typesense. You’d create a
bookings
collection that has records like this:
Copy code
{
  "house_id": 1,
  "booking_id": 1,
  "booking_starts_at": 12345567,
  "booking_ends_at": 12348999
}
{
  "house_id": 1,
  "booking_id": 2,
  "booking_starts_at": 12349322,
  "booking_ends_at": 12350021
}
{
  "house_id": 2,
  "booking_id": 3,
  "booking_starts_at": 12349322,
  "booking_ends_at": 12350021
}
And another
houses
collection that looks like this:
Copy code
{
  "house_id": 1,
  "bed_rooms": 3,
  "pool": true,
  "parking_spots": 2
}
You’d first do a query to the
bookings
collection to get all booking records within the user selected time range. Then take the unique house_ids from the above query, and do another query to the
houses
collection to say get me all houses that don’t have a house_id from the above query, but match the other amenities filter the user might have selected
l
Got it! Thanks for the response
👍 1