We have an issue with the querying of our API, specifically the count of stores that get returned for a query, lat/lng
versus a product_id, lat/lng
.
One the first API call (use postman, curl or a plain browser to view results)
We are quering for Suntory Hibiki Limited 17 Year Old Blended Whisky 750
at a lat/lng of 37.8857582/-122.1180201
.
We get the following response:
{
"results": [
{
"lowPrice": 169.99,
"avgPrice": 313.44,
"highPrice": 699.99,
"id": 459295,
"name": "Hibiki Limited Edition 17 Year Old Blended Whisky",
"brandId": 15470,
"brandName": "Suntory",
"brandProductName": "Suntory Hibiki Limited Edition 17 Year Old Blended Whisky",
"container": "bottle",
"displaySize": "750ml",
"packaging": "Single",
"pricesCount": 11,
"productIds": [
459295
],
"years": [
""
],
"relevancyScore": "0.97",
"elasticScore": 44.276443,
"images": {
"thumb": "https://dw95zbr0bn7mn.cloudfront.net/compare/asset/21816/thumb_compare::product-459295-017052ba-0797-4a04-9a21-f476a0dc5a89.jpg",
"small": "https://dw95zbr0bn7mn.cloudfront.net/compare/asset/21816/small_compare::product-459295-017052ba-0797-4a04-9a21-f476a0dc5a89.jpg",
"large": "https://dw95zbr0bn7mn.cloudfront.net/compare/asset/21816/large_compare::product-459295-017052ba-0797-4a04-9a21-f476a0dc5a89.jpg"
}
}
],
"filters": {
"productContainer": {
"displayName": "Container",
"options": [
{
"filterValue": "bottle",
"count": 1,
"displayName": "Bottle"
}
]
},
"productTypeName": {
"displayName": "Type Name",
"options": [
{
"filterValue": "Liquor",
"count": 1,
"displayName": "Liquor"
}
]
},
"productCountry": {
"displayName": "Country",
"options": [
{
"filterValue": "Japan",
"count": 1,
"displayName": "Japan"
}
]
},
"productYears": {
"displayName": "Years",
"options": []
},
"productPackaging": {
"displayName": "Packaging",
"options": [
{
"filterValue": "Single",
"count": 1,
"displayName": "Single"
}
]
}
}
}
The issue is the low_price, average_price and high_price
and the pricesCount
.
pricesCount
returns as 11, which is the number of stores in the nested stores index.
Its seems that the query is ignoring the filtering for stores geolocation and is including all stores in its calcs. We are querying index compare-product_searches_group_by_sizes
and the query is in this Gist as query1.json
.
On the second API call (use postman, curl or a plain browser to view results)
https://app.frootbat.com/api/v4/products_group_by_sizes/459295?lat=37.8857582&lng=-122.1180201
We are asking for product_id for 459295
at a lat/lng of 37.8857582/-122.1180201
.
We get the following response:
{
"lowPrice": 199.99,
"avgPrice": 372.57,
"highPrice": 699.99,
"id": 459295,
"name": "Hibiki Limited Edition 17 Year Old Blended Whisky",
"brandId": 15470,
"brandName": "Suntory",
"container": "bottle",
"displaySize": "750ml",
"packaging": "Single",
"pricesCount": 7,
"productIds": [
459295
],
"years": [
""
],
"relevancyScore": "0.97",
"description": "",
"country": "Japan",
"rank": null,
"images": {
"thumb": "https://dw95zbr0bn7mn.cloudfront.net/compare/asset/21816/thumb_compare::product-459295-017052ba-0797-4a04-9a21-f476a0dc5a89.jpg",
"small": "https://dw95zbr0bn7mn.cloudfront.net/compare/asset/21816/small_compare::product-459295-017052ba-0797-4a04-9a21-f476a0dc5a89.jpg",
"large": "https://dw95zbr0bn7mn.cloudfront.net/compare/asset/21816/large_compare::product-459295-017052ba-0797-4a04-9a21-f476a0dc5a89.jpg"
},
"varietal": {
"id": 3,
"name": "Blended Whisky",
"displayName": "Blended Whisky"
},
"region": {
"id": 8,
"name": "Japanese Whisky",
"displayName": "Japanese Whisky"
},
"tastingNotes": [],
"reviews": [],
"avgReviewScore": null
}
pricesCount
returns as 7, as well as the low_price, average_price and high_price
being different, so clearly some the filtering is working here.
We are querying index compare-product_searches_group_by_sizes
and the query is in this Gist as query2.json
.
You can see the actual output of it here in the frootbat.com site.
https://frootbat.com/search/Suntory-Hibiki-Limited-17-Year-Old-Blended-Whisky-750/California,-United-States https://frootbat.com/product/459295/Suntory-Hibiki-Limited-Edition-17-Year-Old-Blended-Whisky-750ml-Bottle/California,-United-States
The search page shows a prices count of 11, whereas the product page has 7 prices, so first is not being filtered, second is.