【问题标题】:How to search by properties of an index如何按索引的属性进行搜索
【发布时间】:2023-01-12 06:25:41
【问题描述】:

我必须检索使用具有特定 ID 的应用程序的用户列表:

const users = algoliaClient.initIndex('users')
return users.search('myId123', { hitsPerPage: 50 });

但是用户对象就像这样:

{apps: [
    {id: 'myId123'},
    {id: 'anotherId456'},
    {id: 'anotherId789'},
]}

如何在索引中搜索具有包含具有此类 ID 的对象的应用程序属性的项目?

【问题讨论】:

    标签: algolia


    【解决方案1】:

    如果在属性和子对象属性名称之间添加一个句点,则可以将其添加到“可搜索属性”配置值中以使其可搜索。例如,如果我希望 apps 属性数组中的 id 属性可搜索,我会像这样配置它:

    【讨论】:

      猜你喜欢
      • 2011-10-17
      • 2014-05-24
      • 2014-06-07
      • 1970-01-01
      • 2018-05-12
      • 2016-05-29
      • 1970-01-01
      • 2014-11-29
      • 2016-03-28
      相关资源
      最近更新 更多