Area visualization

Hi,
this my data source:

{
"bookings": [
{
"bookingId": 553267,
"bookingRef": "VO20200108460",
"statusId": 1,
"status": "Confirmed",
"rating": 4,
"hotelId": 17060,
"hotelName": "Nerolia Hotel & SPA 4*",
"hotelCity": "Monastir",
"hotelCountry": "Tunisie",
"hotelAddress": "Zone Touristique Dkhila Skanes,Monastir",
"price": 160,
"arrDate": "2020-01-31",
"depDate": "2020-02-02"
},
{
"bookingId": 553258,
"bookingRef": "VO20200108460",
"statusId": 1,
"status": "Confirmed",
"rating": 4,
"hotelId": 17060,
"hotelName": "Magic Hotels Royal Kenz 4*",
"hotelCity": "Monastir",
"hotelCountry": "Tunisie",
"hotelAddress": "Zone Touristique,Monastir",
"price": 200,
"arrDate": "2020-01-05",
"depDate": "2020-01-07"
},
{
"bookingId": 553456,
"bookingRef": "VO20200108460",
"statusId": 1,
"status": "Confirmed",
"rating": 3,
"hotelId": 17060,
"hotelName": "Les Colombes 3*",
"hotelCity": "Hammamet",
"hotelCountry": "Tunisie",
"hotelAddress": "Route Touristique El Mrazga, Hammamet 8050",
"price": 92,
"arrDate": "2020-01-05",
"depDate": "2020-01-06"
}
]
}

I want to build a visualization that presents: a price comparison for a hotel unit. ie: for the same rating and the same city the area will give a price comparison for the two hotels.

in this case i want to compare the price of "Magic Hotels Royal Kenz 4*" and "Nerolia Hotel & SPA 4*" because they are in the same city and they have the same rating.

y-axe: price
x-axe: date = depDate _ arrDate (i try to calculate the date with scriptedfield but it's don't work for me)

how can i create this visualization please !

Hi @hiba,
From your description, you'll need to set up a few queries and filters so I recommend you take a look at using the Timeseries Visual Builder.

First though, I think you'll need to do a few things:

  1. I notice that your source contains an array of booking documents and you'd need to index each of these separately to query them. i.e. for each item in the bookings array, you would index it using, for example, a PUT request:
PUT hotel-bookings/_doc/3
{
  "bookingId": 553456,
  "bookingRef": "VO20200108460",
  "statusId": 1,
  "status": "Confirmed",
  "rating": 3,
  "hotelId": 17060,
  "hotelName": "Les Colombes 3*",
  "hotelCity": "Hammamet",
  "hotelCountry": "Tunisie",
  "hotelAddress": "Route Touristique El Mrazga, Hammamet 8050",
  "price": 92,
  "arrDate": "2020-01-05",
  "depDate": "2020-01-06"
}

You'll probably want to use a bulk request.

Alternatively, you can set up a pipeline that uses a scripted field to take each entry in the bookings array and index it as a separate document, then reindex your existing data into a new index for querying and visualizing.

  1. You'll need to make sure your arrDate and depDate fields are date types and provide the format for them: YYYY-MM-DD to use date math in scripted fields.
    Once you have your data in the new form, I think you'll find it easier to get to the visualization you want.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.