You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Google Places Insights API筛选仅主营酒吧的场所

解决新版Places Insights API统计主营酒吧的问题

你的查询结果包含附带酒吧的餐厅,是因为includedTypes: ["bar"]会匹配所有包含bar类型(无论主次)的场所。要只获取主营酒吧的场所,可以通过以下两种方式修改:

方式一:排除餐饮类场所类型

在typeFilter中添加excludedTypes,排除常见的餐饮类型,避免包含附带酒吧的餐厅:

{
    "insights": ["INSIGHT_COUNT"],
    "filter": {
        "locationFilter": {
            "region": {
                "place": "places/ChIJIQBpAG2ahYAR_6128GcTUEo"
            }
        },
        "typeFilter": {
            "includedTypes": ["bar"],
            "excludedTypes": ["restaurant", "cafe", "fast_food_restaurant", "food_court"]
        }
    }
}

方式二:指定仅匹配主营类型为Bar的场所

如果你使用的API版本支持primaryTypeFilter参数,可以直接过滤主营类型为bar的场所,这是更精准的方式:

{
    "insights": ["INSIGHT_COUNT"],
    "filter": {
        "locationFilter": {
            "region": {
                "place": "places/ChIJIQBpAG2ahYAR_6128GcTUEo"
            }
        },
        "primaryTypeFilter": {
            "includedPrimaryTypes": ["bar"]
        }
    }
}

说明

  • 方式一通过排除餐饮类类型,能有效过滤掉把酒吧作为附属服务的餐厅;
  • 方式二直接匹配主营类型,结果更精准,但需要确认API版本是否支持primaryTypeFilter参数。

内容的提问来源于stack exchange,提问作者onesiumus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 13:43:16