Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Lucene 的搜索 API 接收“hitsPerPage”参数。看起来它对搜索性能有重大影响。例如,我尝试将其从 100 减少到 10,并且发现搜索时间减少了两倍。
可以吗?为什么会影响搜索性能?是否说明有问题?
hitsPerPage可以这么说,指定页面的大小。将其视为 Google 搜索结果:您可以指定在每个页面上获得的结果数量(“命中”)。
hitsPerPage
如果您只想要hitsPerPage点击,那很好,但如果您想要更多,您将不得不检索更多页面。
为什么它会影响搜索性能?
因为当您想要更小的页面时,Lucene 可以减少工作量(通过返回更少的匹配器文档)。更多点击意味着检索更多文档,这反过来意味着在更多文件中寻找更多位置。