在文档中心打开(侧栏导航) · English

聚合统计

对指定分面(facet)做查询与命中统计,常用于筛选、聚合展示。

接口概览

方法 POST
路径 /1/indexes/{indexName}/facets/{facetName}/query
Base URL 示例 https://api.prophetes.ai
完整 URL 示例 https://api.prophetes.ai/1/indexes/{indexName}/facets/{facetName}/query

Demo 下载

下载我们的官方 Demo,快速将 Insight 搜索集成到您的应用中:

Python Demo
使用标准库 urllib,无需额外依赖
Java Demo
使用 java.net.http.HttpClient,无第三方依赖

鉴权

Header 说明
x-insight-application-id 应用 ID
x-insight-api-key API Key
Content-Type application/json

请求体格式

请求体为 JSON,常用字段:paramsfacetQuerymaxFacetHits

{
  "params": "hitsPerPage=2&getRankingInfo=1",
  "facetQuery": "",
  "maxFacetHits": 15
}

请求参数

参数 类型 必填 默认 说明
params string "" 分页等控制,query string 形式
facetQuery string "" 为空统计全部;有值时仅统计匹配该前缀/关键词的分面值
maxFacetHits integer 15 最大返回分面条数

响应结构

{
  "facetHits": [
    { "count": 5, "highlighted": "Bathroom <em>Furniture</em>", "value": "Bathroom Furniture" }
  ],
  "exhaustiveFacetsCount": true,
  "processingTimeMS": 44
}

示例

curl -X POST "https://api.prophetes.ai/1/indexes/INSIGHT_INDEX_NAME/facets/INSIGHT_FACET_NAME/query" \
  -H "Content-Type: application/json" \
  -H "x-insight-api-key: INSIGHT_API_KEY" \
  -H "x-insight-application-id: INSIGHT_APPLICATION_ID" \
  -d '{"facetQuery":"Furniture","maxFacetHits":15,"params":"hitsPerPage=2&getRankingInfo=1"}'