elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.68k stars 8.23k forks source link

[Maps] Vector map layers will not render when runtime field has '%' #135443

Closed jeffvestal closed 2 years ago

jeffvestal commented 2 years ago

Kibana version: 8.3.0

Elasticsearch version: 8.3.0

Original install method (e.g. download page, yum, from source, etc.): Elastic Cloud

Describe the bug: When a Documents layer with vector scaling is created from a data view that contains a runtime field, the layer does not render.

Steps to reproduce:

  1. Run console commands to create test index

    PUT test/_mapping
    {
      "properties": {
        "price": {
          "type": "keyword"
        },
        "location": {
          "type": "geo_point"
        }
      }
    }
    
    PUT test/_doc/1
    {
        "price" : "$200.00",
        "location": "25,25"
    }
  2. Create test data view.
  3. Add runtime field price_as_number

    if (doc['price'].size() != 0){
      String tmp=dissect('$%{price}').extract(doc["price"].value)?.price;
    
      tmp = tmp.replace(',','');
    
      def pn = Double.parseDouble( tmp );
    
      if (pn != null) emit(pn);
    }
    else { 
      emit(0)
    }
  4. Create new map and add a Documents layer with test data view
  5. Ensure Use vector tiles is selected for Scaling

Expected behavior: Map will render documents' geo_point

Screenshots (if relevant):

maps vector runtime field unable to load layer

Errors in browser console (if relevant): Error example in layer editor (documents -> vector)

Unable to load 7 tiles: tile '12/1051/1522' failed to load: '400 AJAXError: (400): /api/maps/mvt/getTile/12/1051/1522.pbf?geometryFieldName=location&index=airbnb-chicago-listings&hasLabels=false&requestBody=(_source%3A!f%2Cdocvalue_fields%3A!()%2Cquery%3A(bool%3A(filter%3A!((range%3A('%40timestamp'%3A(format%3Astrict_date_optional_time%2Cgte%3A'2021-06-29T05%3A00%3A00.000Z'%2Clte%3A'2022-06-29T14%3A52%3A18.664Z'))))%2Cmust%3A!()%2Cmust_not%3A!()%2Cshould%3A!()))%2Cruntime_mappings%3A(bathrooms_num%3A(script%3A(source%3A'try%20%7B%0A%20%20if%20(doc%5B!'bathrooms_text!'%5D.size()%20!!%3D%200)%7B%0A%20%20%20%20String%20tmp%3Ddissect(!'%25%7Bbathrooms%7D%20%25%7B%7D!').extract(doc%5B%22bathrooms_text%22%5D.value)%3F.bathrooms%3B%0A%0A%20%20def%20bathrooms%20%3D%20Double.parseDouble(%20tmp%20)%3B%0A%0A%20%20if%20(bathrooms%20!!%3D%20null)%20emit(bathrooms)%3B%0A%20%20%7D%0A%20%20else%20%7B%20emit(0)%7D%0A%7D%20%0Acatch(Exception%20e)%20%7B%0A%20%20emit%20(0.5)%0A%7D%0A')%2Ctype%3Adouble)%2Cbedrooms_count%3A(script%3A(source%3A'%20%20if%20(doc%5B!'bedrooms!'%5D.size()%20!!%3D%200)%7B%0A%20%20%20%20%20%20emit(doc%5B!'bedrooms!'%5D.value)%0A%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20emit(0)%0A%20%20%7D')%2Ctype%3Along)%2Cbeds_count%3A(script%3A(source%3A'%20%20if%20(doc%5B!'beds!'%5D.size()%20!!%3D%200)%7B%0A%20%20%20%20%20%20emit(doc%5B!'beds!'%5D.value)%0A%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20emit(0)%0A%20%20%7D')%2Ctype%3Along)%2Cprice_num%3A(script%3A(source%3A'%20%20if%20(doc%5B!'price!'%5D.size()%20!!%3D%200)%7B%0A%20%20%20%20String%20tmp%3Ddissect(!'%24%25%7Bprice%7D!').extract(doc%5B%22price%22%5D.value)%3F.price%3B%0A%0A%20%20%20%20tmp%20%3D%20tmp.replace(!'%2C!'%2C!'!')%3B%0A%0A%20%20def%20pn%20%3D%20Double.parseDouble(%20tmp%20)%3B%0A%0A%20%20if%20(pn%20!!%3D%20null)%20emit(pn)%3B%0A%20%20%7D%0A%20%20else%20%7B%20emit(0)%7D%0A')%2Ctype%3Adouble))%2Cscript_fields%3A()%2Csize%3A10000%2Cstored_fields%3A!(location))&token=07defc57-4961-4032-86a5-94bcc072d222', tile '12/1051/1523' failed to load: '400
elasticmachine commented 2 years ago

Pinging @elastic/kibana-gis (Team:Geo)

nreese commented 2 years ago

@jeffvestal can you provide an explicit example. Runtime fields are working with sample data web logs. For example, create map and add sample web logs. Style color by hour_of_day, which is a runtime field. Everything renders as expected.

Screen Shot 2022-06-29 at 1 14 15 PM
jeffvestal commented 2 years ago

@nreese One example of a runtime field was to take a string price field, remove the $ and , then create a double field.

I can ping you with creds to my deployment so you can check it out. @nickpeihl checked it out last week also.

  if (doc['price'].size() != 0){
    String tmp=dissect('$%{price}').extract(doc["price"].value)?.price;

    tmp = tmp.replace(',','');

  def pn = Double.parseDouble( tmp );

  if (pn != null) emit(pn);
  }
  else { emit(0)}
nreese commented 2 years ago

Is your example for a sample data set? If not, do you mind providing an index mapping and sample document?

jeffvestal commented 2 years ago

This is the airbnb chicago listings

mappings

  "airbnb-chicago-listings": {
    "mappings": {
      "_meta": {
        "created_by": "file-data-visualizer"
      },
      "properties": {
        "@timestamp": {
          "type": "date"
        },
        "accommodates": {
          "type": "long"
        },
        "amenities": {
          "type": "text"
        },
        "availability_30": {
          "type": "long"
        },
        "availability_365": {
          "type": "long"
        },
        "availability_60": {
          "type": "long"
        },
        "availability_90": {
          "type": "long"
        },
        "bathrooms_text": {
          "type": "keyword"
        },
        "bedrooms": {
          "type": "long"
        },
        "beds": {
          "type": "long"
        },
        "calculated_host_listings_count": {
          "type": "long"
        },
        "calculated_host_listings_count_entire_homes": {
          "type": "long"
        },
        "calculated_host_listings_count_private_rooms": {
          "type": "long"
        },
        "calculated_host_listings_count_shared_rooms": {
          "type": "long"
        },
        "calendar_last_scraped": {
          "type": "date",
          "format": "iso8601"
        },
        "description": {
          "type": "text"
        },
        "first_review": {
          "type": "date",
          "format": "iso8601"
        },
        "has_availability": {
          "type": "keyword"
        },
        "host_about": {
          "type": "text"
        },
        "host_acceptance_rate": {
          "type": "keyword"
        },
        "host_has_profile_pic": {
          "type": "keyword"
        },
        "host_id": {
          "type": "keyword"
        },
        "host_identity_verified": {
          "type": "keyword"
        },
        "host_is_superhost": {
          "type": "keyword"
        },
        "host_listings_count": {
          "type": "long"
        },
        "host_location": {
          "type": "text"
        },
        "host_name": {
          "type": "keyword"
        },
        "host_neighbourhood": {
          "type": "keyword"
        },
        "host_picture_url": {
          "type": "keyword"
        },
        "host_response_rate": {
          "type": "keyword"
        },
        "host_response_time": {
          "type": "keyword"
        },
        "host_since": {
          "type": "date",
          "format": "iso8601"
        },
        "host_thumbnail_url": {
          "type": "keyword"
        },
        "host_total_listings_count": {
          "type": "long"
        },
        "host_url": {
          "type": "keyword"
        },
        "host_verifications": {
          "type": "text"
        },
        "id": {
          "type": "keyword"
        },
        "instant_bookable": {
          "type": "keyword"
        },
        "last_review": {
          "type": "date",
          "format": "iso8601"
        },
        "last_scraped": {
          "type": "date",
          "format": "iso8601"
        },
        "latitude": {
          "type": "double"
        },
        "license": {
          "type": "text"
        },
        "listing_url": {
          "type": "keyword"
        },
        "location": {
          "type": "geo_point"
        },
        "longitude": {
          "type": "double"
        },
        "maximum_maximum_nights": {
          "type": "long"
        },
        "maximum_minimum_nights": {
          "type": "long"
        },
        "maximum_nights": {
          "type": "long"
        },
        "maximum_nights_avg_ntm": {
          "type": "double"
        },
        "minimum_maximum_nights": {
          "type": "long"
        },
        "minimum_minimum_nights": {
          "type": "long"
        },
        "minimum_nights": {
          "type": "long"
        },
        "minimum_nights_avg_ntm": {
          "type": "double"
        },
        "name": {
          "type": "text"
        },
        "neighborhood_overview": {
          "type": "text"
        },
        "neighbourhood": {
          "type": "keyword"
        },
        "neighbourhood_cleansed": {
          "type": "keyword"
        },
        "number_of_reviews": {
          "type": "long"
        },
        "number_of_reviews_l30d": {
          "type": "long"
        },
        "number_of_reviews_ltm": {
          "type": "long"
        },
        "picture_url": {
          "type": "keyword"
        },
        "price": {
          "type": "keyword"
        },
        "property_type": {
          "type": "keyword"
        },
        "review_scores_accuracy": {
          "type": "double"
        },
        "review_scores_checkin": {
          "type": "double"
        },
        "review_scores_cleanliness": {
          "type": "double"
        },
        "review_scores_communication": {
          "type": "double"
        },
        "review_scores_location": {
          "type": "double"
        },
        "review_scores_rating": {
          "type": "double"
        },
        "review_scores_value": {
          "type": "double"
        },
        "reviews_per_month": {
          "type": "double"
        },
        "room_type": {
          "type": "keyword"
        },
        "scrape_id": {
          "type": "date",
          "format": "yyyyMMddHHmmss"
        }
      }
    }
  }
}```

sample doc
  {
    "_index": "airbnb-chicago-listings",
    "_id": "QrTBh4EB8MMny-skTcLX",
    "_score": 1,
    "_source": {
      "host_verifications": "['email', 'phone', 'facebook', 'reviews', 'kba']",
      "picture_url": "https://a0.muscache.com/pictures/e32ef032-c20b-4f07-8cf0-30fa3d94f4bb.jpg",
      "calendar_last_scraped": "2022-03-31",
      "first_review": "2019-02-15",
      "neighborhood_overview": "*Highly sought after neighborhood in Chicago! <br />*Within a 10 min walk of hundreds of incredible restaurants, cafes( including a Starbucks and a local roasters with the best coffee in the Midwest) clothing boutiques, grocery stores, convenience stores, killer taco joints, bars, live music venues and much more! <br />*It's easy to get around with the blue line train (which takes you to/from airport) a 5 min walk away plus tons of busses and easy access to the major highways! Although, you don't really need to leave the neighborhood. <br />*I have lived all over the city and this is hands down the best location! Whether you want the real Chicago experience or you're working and need easy access to downtown or any other parts of the city, this is where you need to be! <br />*Street parking is available for free on many of the side streets in this neighborhood. But, select blocks are permit parking after 6pm. Please make sure to read the signs and not park in a residential permit zone. ",
      "number_of_reviews": 7,
      "review_scores_cleanliness": 5,
      "review_scores_checkin": 5,
      "host_location": "Chicago, Illinois, United States",
      "neighbourhood": "Chicago, Illinois, United States",
      "price": "$226.00",
      "reviews_per_month": 0.18,
      "review_scores_location": 5,
      "id": "20054600",
      "host_identity_verified": "t",
      "longitude": -87.67084,
      "review_scores_accuracy": 4.86,
      "host_response_time": "N/A",
      "review_scores_value": 4.86,
      "bedrooms": 2,
      "license": "Registration Number: R17000017884",
      "minimum_nights_avg_ntm": 2.3,
      "name": "Beautiful Condo w/ Skyline Views & Private Decks",
      "availability_60": 0,
      "host_thumbnail_url": "https://a0.muscache.com/im/pictures/user/071b942e-a7fc-450e-9345-8d8c0f94f3cf.jpg?aki_policy=profile_small",
      "host_neighbourhood": "Ukrainian Village",
      "minimum_maximum_nights": 1125,
      "beds": 3,
      "scrape_id": "20220317023945",
      "instant_bookable": "f",
      "calculated_host_listings_count_entire_homes": 3,
      "amenities": """["Essentials", "Patio or balcony", "Iron", "Refrigerator", "Hot water", "First aid kit", "Air conditioning", "Microwave", "Hangers", "Coffee maker", "Cable TV", "Kitchen", "Dishwasher", "Fire extinguisher", "Private entrance", "Carbon monoxide alarm", "Cooking basics", "TV with standard cable", "Luggage dropoff allowed", "Smart lock", "Stove", "Heating", "Smoke alarm", "Wifi", "Dishes and silverware", "Dedicated workspace", "Free street parking", "Oven", "Shampoo", "BBQ grill", "Indoor fireplace", "Hair dryer"]""",
      "host_url": "https://www.airbnb.com/users/show/38111959",
      "maximum_maximum_nights": 1125,
      "neighbourhood_cleansed": "West Town",
      "minimum_minimum_nights": 2,
      "latitude": 41.90239,
      "maximum_nights_avg_ntm": 1125,
      "description": """-Penthouse with private rooftop deck with incredible views of Chicago skyline <br />-Beautiful home with modern furnishings, professional-grade appliances, and three private decks<br />-Sleeps 5 in 3 beds (king bed in master BR, air mattress in adjacent loft, non-pull-out couch in living room)<br />-Blocks from Blue Line train<br />-Blocks from ride share bike station<br />-15 minute ride to Michigan Avenue<br /><br /><b>The space</b><br />*Large open floor plan with beautiful hardwood and marble floors<br />*Brand new, modern kitchen with professional-grade appliances and breakfast bar<br />*Huge master suite with fancy king-sized bed and en-suite bathroom with double vanities, water closet, soaking tub with TV and spa shower, and sliding doors opening to second floor private balcony<br />*Loft space off master bedroom functions as additional bedroom with room for 1 queen sized air mattresses<br />*Living room features 52" 4K flat screen tv and large windows and doors opening on to pr""",
      "review_scores_communication": 5,
      "has_availability": "t",
      "property_type": "Entire condo",
      "host_response_rate": "N/A",
      "availability_90": 0,
      "calculated_host_listings_count_shared_rooms": 0,
      "calculated_host_listings_count_private_rooms": 0,
      "availability_365": 0,
      "availability_30": 0,
      "listing_url": "https://www.airbnb.com/rooms/20054600",
      "maximum_minimum_nights": 3,
      "maximum_nights": 15,
      "number_of_reviews_ltm": 0,
      "host_picture_url": "https://a0.muscache.com/im/pictures/user/071b942e-a7fc-450e-9345-8d8c0f94f3cf.jpg?aki_policy=profile_x_medium",
      "host_has_profile_pic": "t",
      "bathrooms_text": "1 bath",
      "number_of_reviews_l30d": 0,
      "host_id": "38111959",
      "host_listings_count": 3,
      "host_total_listings_count": 3,
      "host_acceptance_rate": "N/A",
      "review_scores_rating": 5,
      "@timestamp": "2022-03-17T02:39:45.000-05:00",
      "minimum_nights": 2,
      "last_review": "2020-02-04",
      "calculated_host_listings_count": 3,
      "accommodates": 5,
      "host_is_superhost": "t",
      "location": "41.90239,-87.67084",
      "host_since": "2015-07-10",
      "last_scraped": "2022-03-31",
      "host_name": "Joanna (Dba Blue Sky Home Rentals)",
      "room_type": "Entire home/apt"
    }
  }
nreese commented 2 years ago

Thanks, I am able to re-create the problem on main. I have updated issue comment with more detailed test instructions

nreese commented 2 years ago

I have isolated the problem. The % character in the runtime field is causing decodeURIComponent call to throw URI malformed exception.