duan111112 2017-09-14 19:20
浏览 160

blevesearch如何分页结果?

I'm trying to integrate blevesearch in my app. How am I supposed to implement pagination? I can't find any param to indicate the page number, per-page limit or cursor in the docs.

  • 写回答

1条回答 默认 最新

  • douling1936 2019-08-21 17:06
    关注

    I ran into this issue while trying to add pagination to the gozim project, and I used JimB's comment to find a solution. I updated this:

    queryString := r.FormValue("search_data")
    query := bleve.NewQueryStringQuery(queryString)
    search := bleve.NewSearchRequest(query)
    

    To this:

    queryString := r.FormValue("search_data")
    pageString := r.FormValue("page")
    pageNumber, _ := strconv.Atoi(pageString)
    itemCount := 20
    from := itemCount * pageNumber
    query := bleve.NewQueryStringQuery(queryString)
    search := bleve.NewSearchRequestOptions(query, itemCount, from, false)
    

    And it appears to be working correctly.

    评论

报告相同问题?

悬赏问题

  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证