algolia响应仅返回json数组,而没有分页参数

问题描述

我试图通过以下代码从阿尔及利亚响应中获得分页结果

index.search('l',{
  attributesToRetrieve: ['pName'],hitsPerPage: 9
}).then(({
    hits
  }) => {
  var respondString = JSON.stringify(hits);
  console.log('response equals  == ' +respondString);
}).catch(function (e) {});

当我记录响应时,它以数组格式给了我这个json->>

[
    {
      "pName": "laptop10","objectID": "3770345000","_highlightResult": {
        "pName": {
          "value": "<em>l<\/em>aptop10","matchLevel": "full","fullyHighlighted": false,"matchedWords": [
            "l"
          ]
        }
      }
    },{
      "pName": "laptop3","objectID": "3770344000","_highlightResult": {
        "pName": {
          "value": "<em>l<\/em>aptop3",{
      "pName": "laptop4","objectID": "37703240","_highlightResult": {
        "pName": {
          "value": "<em>l<\/em>aptop4","matchedWords": [
            "l"
          ]
        }
      }
    }
  ]

但是我希望这样的结果可以使我的数据分页

{
  "hits": [
    {
      "pName": "laptop10","matchedWords": [
            "l"
          ]
        }
      }
    }
  ],"nbHits": 10,"page": 0,"nbPages": 1,"hitsPerPage": 15,"exhaustiveNbHits": true,"query": "l","params": "attributesToRetrieve=%5B%22pName%22%5D&hitsPerPage=15&query=l","processingTimeMS": 1
 
}

如您所见,我需要nbHits来确定给定查询的总结果计数,并且需要page来了解用户所在的当前页面

很高兴?如果有人可以帮助我

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...