有没有办法将 Algolia 索引中的所有数据显示为 html 中的列表?

Is there a way to display all data in Algolia index as list in html?

我想将 Angolia 索引中的所有数据显示为 html 页面中的列表。我正在使用 Firestore 镜像 Angolia 数据库,目前它正在运行,因此可以显示我的 Firestore 数据,但我想改为从 Algolia 提取数据,然后可能对其进行过滤。

供稿

<ais-instantsearch [config] = "searchConfig">

  <ais-search-box (change)="searchChanged($event)"></ais-search-box>

  <ais-hits *ngIf="showResults">

    <ng-template let-hits="hits">

        <div *ngFor="let hit of hits">

          <div>
            {{hit.description}}
          </div>

        </div>


    </ng-template>

  </ais-hits>

</ais-instantsearch>

这就是我在搜索我的 Algolia 数据时所做的工作,并且有效。但我希望页面加载后,我在 html 中始终显示我正在搜索的所有数据。

这取决于索引中的记录数。您可以使用参数 hitsPerPage. You can provide this parameter with the ais-configure 小部件控制引擎 returns 的记录数。

请注意,默认情况下 hitsPerPage cannot go over 1000. You can increase this limit with the settings paginationLimitedTo. You cannot set this value from InstantSearch. It must be either a call to setSettings 或更新 Algolia 仪表板内的值。

此方案适用于InstantSearch,限制在索引中有少量记录。对于某些用例,这不是一个可行的解决方案。您可以选择退出 InstantSearch 以使用 browse method. It allows you to get the full content of your index without any restrictions on the number of records. You can find more information in the documentation.